A ssh B主机
A主机无密码登录B主机,假设B主机ip为:173.192.41.2
在A主机下面执行
cd ~
ssh-keygen -d
一路回车,执行输出如下
Generating public/private dsa key pair.
Enter file in which to save the key (/home/TSP/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/TSP/.ssh/id_dsa.
Your public key has been saved in /home/TSP/.ssh/id_dsa.pub.
The key fingerprint is:
61:23:a4:22:8c:af:37:d9:9d:c8:c5:6e:e6:54:eb:a5 TSP@tsp-rls-webservice01
The key's randomart image is:
+--[ DSA 1024]----+
| . |
|o o |
|o.. . . + |
| o . . o o |
| . o S |
| . + = o . |
|. + + B . . |
| . . = . o |
| . E |
+-----------------+
ls ~/.ssh
id_dsa id_dsa.pub
sh-copy-id -i ~/.ssh/id_dsa.pub 173.192.41.2
The authenticity of host '192.168.30.202 (192.168.30.202)' can't be established.
RSA key fingerprint is 69:f8:f9:5a:3a:c7:7e:f2:ad:f3:85:79:43:41:99:3d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.30.202' (RSA) to the list of known hosts.
TSP@192.168.30.202's password:
Now try logging into the machine, with "ssh '192.168.30.202'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
注意:中间过程,需要输入服务端的用户密码
根据上述提示,在客户端使用ssh命令登陆服务端:
如果找不到命令,可以通过scp
scp id_dsa.pub 67.198.146.226:~/.ssh/authorized_keys
ssh 173.192.41.2
执行后可以无密码登录到远程linux