ssh password-free login server

A machine for the local host (i.e., for controlling other host machines)

B is a remote host machine (i.e. a machine control Server) B Machine: 192.168.3.145
If no password B A dryer machine
 
 
A command on the machine:
1, ssh-keygen -t rsa (Enter three times, i.e., public and private keys generated locally, without providing a password)
2, ssh  [email protected]  "mkdir .ssh; chmod 0700 .ssh" (password is required, Note: ssh permissions set to 700 user directory permissions must be 700, for example, I was operating with wutengfei user, then. / home / wutengfei (home directory) permissions best 700)
3, scp ~ / .ssh / id_rsa.pub [email protected]: /root/.ssh/id_rsa.pub (password is required) (scp is a secure copy of abbreviation, scp ssh login security is based on the linux system remote file copy command.)
        
 
On the B command:
# Touch /root/.ssh/authorized_keys (if the file already exists, skip this article)
# Chmod 600 ~ / .ssh / authorized_keys (# Note: You must ~ / .ssh / authorized_keys permissions to 600, the public key file is used to save the ssh client-generated, you can modify the ssh server configuration file server / etc / ssh / sshd_config to specify a different file name)
# Cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys (appended to the contents of id_rsa.pub authorized_keys in, careful not to use>, otherwise it will clear the original content that others do not use the original key login)
 
A return to the machine:
# Ssh [email protected] (no password, the login is successful)
 
 
 
 
 
Note: If you fail to see selinux is open
Close selinux: setenforce 0 (temporarily closed)
                        vim /etc/selinux/config 
                           

The SELINUX = enforcing changed SELINUX = disabled enough to restart

Guess you like

Origin www.cnblogs.com/duidui-li/p/11433873.html