We all know that SSH has been providing two ways to log in: Password authentication method and key authentication method, the password is the way we use most often, and then we talk about using the key to log in.
Client (Windows Xshell) to Server (CentOS6.6)
1. Generate key (public key and private key), Open is Xshell, select menu bar tools-->user key Generation Wizard ...
The following window pops up:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6F/5E/wKiom1WaLK-DI6-DAAGWSh5VTpo859.jpg "title=" 1.jpg " alt= "Wkiom1walk-di6-daagwsh5vtpo859.jpg"/>
Note Key Type Select Rsa,key Length select 2048, and then next:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6F/5B/wKioL1WaLuyCaUzmAAHCBdpkgsM960.jpg "title=" 2.jpg " alt= "Wkiol1waluycauzmaahcbdpkgsm960.jpg"/>
Wait for the key to be generated successfully, and then select Next:
Pop up the following window, fill in the key name, this random, and key verification password (don't forget)
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6F/5E/wKiom1WaLb7Qm4IxAAFYBhJcg1g895.jpg "title=" 3.jpg " alt= "Wkiom1walb7qm4ixaafybhjcg1g895.jpg"/>
To generate the key here is completed, select Next, export the key file,
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6F/5B/wKioL1WaMF3w7bUlAAJNYFxo2-4248.jpg "style=" float: none; "title=" 4.jpg "alt=" Wkiol1wamf3w7bulaajnyfxo2-4248.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6F/5E/wKiom1WaLpGxHHjXAAJROhh7Jwk009.jpg "style=" float: none; "title=" 5.jpg "alt=" Wkiom1walpgxhhjxaajrohh7jwk009.jpg "/>
2. Next is the second step, put testkey.pub to server, there are many ways, you can use scp,ftp, or U disk, here I use a lrzsz tool, if you know the best, do not know the words can read my other blog, http:// ultraera.blog.51cto.com/6640392/1670522
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6F/5C/wKioL1WaMZGAe7gZAAL7_sZ0wPc861.jpg "title=" 6.jpg " alt= "Wkiol1wamzgae7gzaal7_sz0wpc861.jpg"/>
If there is an error such as: Temporarily shut down the firewall.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6F/5E/wKiom1WaMH7Qa0_6AAC428tt4dM994.jpg "title=" 7.jpg " alt= "Wkiom1wamh7qa0_6aac428tt4dm994.jpg"/>
After uploading the key file to the server, you need to do the following:
Replace the contents of the testkey.pub with the/root/.ssh/
[Email protected] ~]# ls-a. .. Testkey.pub[[email protected] ~]# mkdir. Ssh[[email protected] ~]# chmod. Ssh/[[email protected] ~]# CD. Ssh/[[email p Rotected]. ssh]# Cat.. /testkey.pub >/authorized_keys[[email protected]. ssh]# lsauthorized_keys[[email protected]. ssh]# chmod 600 Authorized_keys[[email protected] ~]# diff testkey.pub. Ssh/authorized_keys [email protected] ~]#
Make sure the file content is the same.
3. Next, configure the server's SSH service (/etc/ssh/sshd_config) to allow password logon only with key login:
# line 66PasswordAuthentication No # do not allow password login # line 48,49pubkeyauthentication Yes # Use key to login authorizedkeysfile. Ssh/authorized_keys # Key Name
After saving exits, restart the SSH service.
4. All configurations are complete, then test
First sign in with a password:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6F/5C/wKioL1WaNvKhfDbNAALJlGXpNts727.jpg "title=" 8.jpg " alt= "Wkiol1wanvkhfdbnaaljlgxpnts727.jpg"/> can be seen here the password option is grayed out and is not selectable, and the default option is changed to public Key.
So, next, we select the then key, and enter the password that was set at that time,
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6F/5C/wKioL1WaN-HCxpQTAAF_zBArOsE928.jpg "style=" float: none; "title=" 9.jpg "alt=" Wkiol1wan-hcxpqtaaf_zbarose928.jpg "/>
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6F/5F/wKiom1WaNhXhewvPAAGLfTyIx-U449.jpg "style=" float: none; "title=" 10.jpg "alt=" Wkiom1wanhxhewvpaaglftyix-u449.jpg "/>
Okay, here's the whole process of configuring Xshell to use the key SSH login to CentOS.
If everyone, in the reference tutorial found that there are any problems can give me a message, or direct mail to my email [email protected] (this speed will be faster)
This article from "A cup of boiled water" blog, please be sure to keep this source http://ultraera.blog.51cto.com/6640392/1671351
Xshell Configuring SSH using key Public key (Publice key) login (multi-image, mobile phone caution!) )