Experimental background:
In our actual production, we often need to formulate a reliable password-free login environment, SSH's own public key is our common choice.
Lab Environment:
Virtual machine VMware Workstation under the conditions of the player
Client: centos6.4 system, the system comes with SSH software, ip:192.168.0.24 netmask:255.255.255.0
Server-side: centos6.4 system, the system comes with SSH software, ip:192.168.0.25 netmask:255.255.255.0
For ease of operation I am using the securecrt Remote Connection tool
Let me first introduce that SSH is commonly used when we connect to the Management Server remotely.
One, no time to add SSH trust:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/7C/83/wKioL1bSavyQ-yUKAADKbOBBmus023.png "style=" float: none; "title=" 01.png "alt=" Wkiol1bsavyq-yukaadkbobbmus023.png "/>
Commands for remote connections:
SSH user name @ IP of the server you want to connect to
The first time you connect, you'll need to enter Yes
Ifconfig |grep "inet addr" |cut-d ': '-f 2|cut-d '-F 1
The above command is to make sure that we do log in to view all IP of the host, and you can see that I have two NICs and a loopback address 127.0.0.1
Here is the command to get the IP for a network card.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7C/85/wKiom1bSaoiiC5XHAAAqBXhzA2s694.png "style=" float: none; "title=" 02.png "alt=" Wkiom1bsaoiic5xhaaaqbxhza2s694.png "/>
Second, Add SSH Trust
Exit the connection you just made
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7C/85/wKiom1bSbDnhG7bqAAAg19xQzuY527.png "title=" 03.png "alt=" Wkiom1bsbdnhg7bqaaag19xqzuy527.png "/>
1. We generate the key
Executing commands on the client
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7C/85/wKiom1bSbOLgP4BAAACpZjHNe9U260.png "title=" 05.png "alt=" Wkiom1bsbolgp4baaacpzjhne9u260.png "/>
View our generated keys, typically generated keys in the/ROOT/.SSH directory
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/7C/83/wKioL1bSbdSQcNecAAA2-3yhVkE823.png "title=" 06.png "alt=" Wkiol1bsbdsqcnecaaa2-3yhvke823.png "/>2, copy the generated public key to the server side
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7C/83/wKioL1bSb1PhH6CiAACZ5s9OZ38820.png "title=" 07.png "alt=" Wkiol1bsb1phh6ciaacz5s9oz38820.png "/>
You can see that we did not enter the password on the login success! We don't need a password to log on to the server in the future.
So let's take a look at the Execute command: ssh-copy-id-i/root/.ssh/id_rsa.pub [email protected] What was generated on the server side.
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7C/83/wKioL1bSb_yw2wpiAAAbAcruoUA464.png "title=" 08.png "alt=" Wkiol1bsb_yw2wpiaaabacruoua464.png "/> can see that the file Authorized_keys is generated.
Of course we can create this file ourselves, this blog will not be introduced. I can Baidu search for a bit.
Thank you, I hope we can help you.
This article is from the "Make a few" blog, be sure to keep this source http://9399369.blog.51cto.com/9389369/1745724
SSH password-free login to remote server