Transferred from: http://blog.163.com/tqq_0716/blog/static/7690741220110611350344/
Server a:192.168.1.1
Server b:192.168.1.2
Server A:
Configuration:
Ssh-keygen-b 2048-t RSA
#这里的-B 2048 is the length of the key encryption, it is best to set a large point, there is a message that the United States has hackers to solve the SSH key to crack.
#http://bbs.yuloo.com/thread-860154-1-1.html
Direct Enter 3 times
The key file will be saved in the/ROOT/.SSH directory
At this point, SSH will have a few more files.
Id_rsa private Key File
Id_rsa.pub the public key file, the contents of this file should be placed in other hosts.
View Id_rsa.pub File
Cat/roor/.ssh/id_rsa.pub
Ssh-rsa aaaab3nzac1yc2eaaaabiwaaaicavh6lz9ghftghtfghsv+ksrxvlc9udkq27mg5vhfghaawcgfgllzhfg2dlngotmel/08bp6jmw/ eksq1by1eiouiluiliuliul2rr84x0bb5yshhpgjwupbwr/pymgukyukyukyuthjkiytiliunzdfkuykyuizgvvgptzndn/ rdwjmsafsdvgsdsfsdfdsfsdaflozstycwjrwzyxsrodpby4zjd0gh5zmyhj+vs4ooazz8rthefx+ste0= [email protected]
Server B:
Configuration:
New folder and file
Mkdir/root/.ssh
Vim/root/.ssh/authorized_keys
Copy the contents of the key file viewed on server A to the Authorized_keys of server B
The main thing is to change [email protected] to [email protected] so that it is easy to see which server's key, there may be more than one server key.
Modify the main profile of sshd, turn off password Authentication login, use key to login.
Vim/etc/ssh/sshd_config
Find Passwordauthentication Yes
Change to Passwordauthentication No
Service sshd Restart
Test:
Execute on Server A
SSH [email protected]
The first login will require you to enter Yes. See if you don't need a password to log on to B service.
The method and use of Linux to generate key