Description: As described below
The ' client ' refers to the local machine you are using;
' Service side ' refers to the remote machine you want to connect to;
----------------------------------------------------------
1. First open the Shell window on the client and enter the command to generate the ' public key, private key pair ':
Ssh-keygen-t rsa-p ' #注意参数-P is uppercase
#-p followed by a single quotation mark with a space before the uppercase P
2. Wait for you to enter the generated file to save where, the default location is home directory, General Direct return to
#在没改变存储位置的情况下, a hidden. SSH folder is generated in the home directory, and a public key file is generated in the. SSH folder: Id_rsa.pub, and a private key file: Id_rsa
#.ssh for hidden files, the direct LS display does not come out, to use ls-a to show out, see not see all affect CD. SSH command
3. Use the SCP or other method to copy the public key from the. SSH folder to the server side (I copied it with SCP)
scp/home/pi/.ssh/id_rsa.pub [Email protected]:/home/yang/
#因为是利用scp方式传输的, so you will be prompted to lose the password, if you have implemented SSH password-free login, and then use the SCP when you do not have to lose the password
#其实scp传输的时候也有几个坑, if you have not looked at the SCP document, simply say: 1. In fact, when I pass the file, it is not the command written above, but scp-p 10022/home/pi/.ssh/id_rsa.pub [email protected]:/home/yang/, you can see a more '-P 10022 ', because my SSH server is set SSH port number is 10022, in fact, usually we see the command without port is actually an implicit-P 22 in it ( 22 is the default port when SSH is installed), it is equivalent to you write ' SCP local/Remote remote/local ', SCP will also process, become ' scp-p 22 local/Remote remote/local ' and then send to the remote server
4. Create the. ssh folder in the home directory of the remote server, and then copy the home directory from the local id_rsa.pub to the. SSH folder and rename it to Authorized_keys
#我是在远程服务器上也执行了1中的命令系统给生成的, but this is more than the direct use of mkdir to create trouble, then is to consider whether you create a no, is not in the remote server. SSH was created with the command in 1.
#! Online tutorial is not to first copy id_rsa.pub to. SSH after renaming to Authorized_keys, but home directory directly with the cat Id_rsa.pub >>.ssh/authorized_keys, I think it should be if there are multiple machines that want to password-free to connect to this remote server, you can append multiple local client-generated id_rsa.pub to a file (I just guess, have time to practice)
5. Set the permissions of the Authorized_keys to 600
#chmod Authorized_keys I write directly here Authorized_keys is because the current path is under the. SSH folder, if the current location is not an. SSH folder Authorized_keys must use an absolute path
#之后再连就能连上了, about the connection here is also a point to note, usually everyone is written ' SSH remote server IP ' this way, but some people are so connected but not connected, why? is because the person in this way is connected because the remote server has the same name as the user you are logged on to. and the remote server SSH default port is 22, in order to use that straight way, otherwise, if the remote server SSH connection password has changed, you should add the '-p port number when connecting, if the user name on the remote server is not the same as the user you are logged on locally, you also need to specify '-l username ' to be able, so I connect my remote server is such ' ssh-l yang-p 10022 aaa.bbb.ccc.ddd '. Then again, even with the ' SSH IP address ', as stated earlier, Before the local command sent to the remote server it still processed a bit, the default user name and password parameters added, that is, you write SSH www.xxx.yyy.zzz, but before sending SSH processing again, ssh-l local currently logged on user name-P 22 Www.xxx.yyy.zzz ' then send the processed command to the remote server for login operation; password-free login is based on the above-mentioned reference http://os.51cto.com/art/201209/358478.htm
SSH password-free key login