Deploying Two Linux Servers to Achieve "SSH Key Login" Tutorial - Tech

  1. Portal Home
  2. Tech

Deploying Two Linux Servers to Achieve "SSH Key Login" Tutorial

Background: Some scenarios may use two servers ssh key login. Example: automated server deployment.

Start preparing.

Server A Linux IP:192.168.1.1
Server B Linux IP:192.168.1.2

Step 1.

On Server A, use the following command to generate the secret key.
If a colon (:) returns, press Enter three times. If (yes/no) appears, enter yes

ssh-keygen -t rsa

The part marked in red is the path where the file is saved.

Step 2.
on server A. Enter a command pointing to the IP address of server B, with the root account.

ssh-copy-id -i ~/.ssh/id_rsa.pub   [email protected]

Then, the account password for Server B needs to be entered.

Note: If the ssh-copy-id -i command reports an error, clear the contents of the file ".ssh/authorized_keys" on Server B and retransmit the public key.