First, prepare two Linux OS hosts. The VM is used here.
First:
[Email protected]: ~ $ Hostname
Chiwei-virtualbox
IP: 192.168.8.144
Second:
[Email protected]: ~ /. Ssh $ hostname
Chiwei-hadoop
IP: 192.168.8.200
Install the OpenSSH-server http://blog.csdn.net/simonchi/article/details/38871953 on both machines separately.
After the installation is complete, you can use the SSH command.
Run ssh-keygen-t rsa on the first Server
[Email protected]: ~ $ Ssh-keygen-T RSA
Generating public/private RSA key pair.
Enter file in which to save the key (/home/chiwei/. Ssh/id_rsa ):
Enter passphrase (empty for no passphrase ):
Enter same passphrase again:
Your identification has been saved in/home/chiwei/. Ssh/id_rsa.
Your public key has been saved in/home/chiwei/. Ssh/id_rsa.pub.
The key fingerprint is:
1D: 45: B5: A3: 54: 6e: A7: F6: 65: 79: 27: 9B: A6: 1c: D4: D2 [email protected]
The key's randomart image is:
+ -- [RSA 2048] ---- +
|. O. o |
|. O. |
|... =. |
|. O = +. |
| S. + E. = |
|. O * + |
|. +. |
|. + |
| O |
+ ----------------- +
Run CP id_rsa.pub authorized_keys
Run
[Email protected]: ~ /. Ssh $ SCP authorized_keys [email protected]:/home/chiwei/. SSH
[Email protected]'s password:
Authorized_keys 100% 406 0.4kb/s
[Email protected]: ~ /. Ssh $ SSH chiwei-hadoop
Welcome to Ubuntu 14.04 lts (GNU/Linux 3.small-24-generic x86_64)
* Documentation: https://help.ubuntu.com/
359 packages can be updated.
6 updates are security updates.
Go to the second server to view
[Email protected]: ~ /. Ssh $ ls
Authorized_keys id_rsa id_rsa.pub
[Email protected]: ~ /. Ssh $
The file has been uploaded.
Now you can log on to the first host directly using ssh on the second host.
Remote login via SSH in Ubuntu requires no password