标签:
目标:system1透过ssh连接到system2电脑
步骤如下:
# ssh-keygen -t rsa
Enter file in which to save the key (~/.ssh/id_rsa):
Created directory ‘~/.ssh‘.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in ~/.ssh/id_rsa.
Your public key has been saved in ~/.ssh/id_rsa.pub.
The key fingerprint is:
1c:fe:8d:10:b5:32:09:95:51:48:df:45:ef:74:5d:dc henry@db0222da7529
The key‘s randomart image is:
+--[ RSA 2048]----+
| .o+=o .o.o|
| .o+ o . .E|
| * o . =|
| o = o.|
| S .|
| o o |
| o . |
| |
| |
+-----------------+
ssh-keygen的参数说明:
-t type
Specifies the type of key to create. The possible values are
``rsa1‘‘ for protocol version 1 and ``dsa‘‘, ``ecdsa‘‘ or ``rsa‘‘
for protocol version 2.
# cat ~/.ssh/id_rsa.pub > ~/.ssh/authorized_keys
注意: 用putty自带的PUTTYGEN.EXE生成会不兼容OpenSSH,从而会导致登录时出现server refused our key错误
做法: 把private key(id_rsa)给拷贝出来,我是用vim或cat来开启id_rsa文件然后用鼠标按右键拷到windows下的剪贴板, 存到一个文本给PUTTYGEN.EXE File/Load private key使用. 接着点击Save private key, 此档案等下要用.
1.开启putty.exe, 设定Connection/data/Auto-login username, 这里我是用root来登入
2.SSH/Auth/Private key file for authentication:点击Browser选择到你保存私钥(.pkk)的文件, 就是 Save private key 的那个档案.
标签:
原文地址:http://www.cnblogs.com/jHenry/p/4254104.html