ssh login-free configuration


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.


Problem: Login is very slowhttp

://blog.csdn.net/huang_xw/article/details/8275569
The most common reason is because the server's sshd will go to DNS to find the hostname of the client IP. If DNS is unavailable or there is no relevant record, it will take a lot of time.
1. Add your local ip and hostname to the /etc/hosts file
on the server 2. Modify or add UseDNS=no to the /etc/ssh/sshd_config file on the server, and it is also possible to authenticate gssapi-with-mic There is a problem, modify GSSAPIAuthentication no
service sshd restart in the /etc/ssh/sshd_config file on the server

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326927172&siteId=291194637