ssh configuration
Host A: 10.0.5.199
Host B: 10.0.5.198 It is
necessary to configure host A to log in to host A without a password. For host B
, make sure that the firewalls of all hosts are turned off.
Execute the following on host A:
1. $cd ~/.ssh
2. $ssh-keygen -t rsa --------------------then keep pressing enter , the generated key will be saved in the .ssh/id_rsa file according to the default options.
3. $cp id_rsa.pub authorized_keys
After this step is completed, you can log in to the machine without a password under normal circumstances, that is, ssh localhost, without entering a password.
4. $scp authorized_keys [email protected]:/home/summer/.ssh ------ Copy the authorized_keys file just generated to host B.
5. $chmod 600 authorized_keys
enter the .ssh of host B directory, change the permissions of the authorized_keys file.
(4 and 5 can be combined in one step, execute: $ssh-copy-id -i [email protected] )
Under normal circumstances, after the above steps are executed, ssh connections are initiated from the machine where host A is located to the machines where host A and host B are located. , the password is only required for the first login, not later.
Possible problems:
1. When logging in with ssh, it appears: Agent admitted failure to sign using the key.
Execute: $ssh-add
2. If there is no error prompt, you can enter the password to log in, but you cannot log in without a password, on the connected host (If A initiates an ssh connection to B, then on B) perform the following steps:
$chmod ow ~/
$chmod 700 ~/.ssh
$chmod 600 ~/.ssh/authorized_keys
3. If step 2 is executed, still If you cannot log in without a password, try the following
$ps -Af | grep agent
to check whether the ssh agent is enabled. If it is enabled, kill the agent, and then execute the following to reopen an ssh agent. If it is not enabled, execute it directly. The following: If
$ssh-agent
still does not work, execute the following, restart the ssh service
$sudo service sshd restart
Note:
The .ssh directory under the $HOME directory in the Linux system is owned by the user, and the permission must be 700 (only the user can Full access);
The authorization file "authorized_keys" in the .ssh directory is owned by the user, and the permission must be 644.
SSH password-free login under Linux
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326430626&siteId=291194637
Recommended
Ranking