Putty使用Key登录服务器的过程

1、Linux下生成密钥

运行:

引用

# ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):  <-密钥路径

Enter passphrase (empty for no passphrase): <-密钥保护密码

Enter same passphrase again:

Your identification has been saved in /root/.ssh/id_rsa. <-私钥

Your public key has been saved in /root/.ssh/id_rsa.pub. <-公钥

The key fingerprint is:

17:28:4c:c3:e4:18:d4:c2:31:bd:be:a7:a9:d4:a8:48 [email protected]

2、把公钥信息写入authorized_keys文件中

运行:

# cd ~/.ssh

# cat id_rsa.pub >> authorized_keys

3、生成putty的私钥

由于SSH的标准中,并没有固定密钥文件的格式。而Putty使用的私钥格式和OpenSSH生成的有点不同,需要转换一下。

a)把id_rsa传到Windows机器上

b)使用puttygen的“Load”读取id_rsa文件

c)点击“Save private key”保留私钥。

d)putty使用该新的私钥登陆服务器即可。

4.使用新的密鑰登錄

  1. putty设置:要连接的服务器地址、用户、密钥文件
  1. 完成上面设置后,点击open连接,可以看到,直接连接到了服务器。

5.保存會話

在保存會話中輸入IP地址,然後點擊載入和保存,即可實現使用key登錄到服務器。

发布了46 篇原创文章 · 获赞 12 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/malingyu/article/details/103990399