Centos 配置密钥,使用xshell远程连接

本片文章讲述centos 如何使用密钥连接系统

方法一

1,在服务器上生成公钥和私钥

[root@wscyun-com ~]# ssh-keygen 
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:
SHA256:K7BmAhEWHsjA2TvAIGQTGhcDHxvOrVipO4eS/XMyYhM root@wscyun-com
The key's randomart image is:
+---[RSA 2048]----+
|/X@.             |
|B&oO             |
|o.O o            |
| = +             |
|+ . o   S        |
| *E  o   .       |
|* +.+ . .        |
|.o+=+ ..         |
| . o.=           |
+----[SHA256]-----+

2,查看刚刚生成的公钥密钥

[root@wscyun-com ~]# ls .ssh/
id_rsa  id_rsa.pub

3,服务器安装公钥

[root@wscyun-com ~]# cd .ssh/
[root@wscyun-com .ssh]# cat id_rsa.pub >> authorized_keys
[root@wscyun-com .ssh]# chmod 600 authorized_keys

4,把私钥拷贝到本地,使用xshell 连接,选择刚刚保存的私钥 id_rsa

图片[1]-Centos 配置密钥,使用xshell远程连接-其乐无穷资源网 - 自动架设游戏基地 | VM一键端 | 手游架设 | 端游架设 | GM

方法二

1,使用xshell 生成密钥对(公钥私钥)

图片[2]-Centos 配置密钥,使用xshell远程连接-其乐无穷资源网 - 自动架设游戏基地 | VM一键端 | 手游架设 | 端游架设 | GM
图片[3]-Centos 配置密钥,使用xshell远程连接-其乐无穷资源网 - 自动架设游戏基地 | VM一键端 | 手游架设 | 端游架设 | GM
图片[4]-Centos 配置密钥,使用xshell远程连接-其乐无穷资源网 - 自动架设游戏基地 | VM一键端 | 手游架设 | 端游架设 | GM

2, 把公钥保存到自己本地,后面要用

图片[5]-Centos 配置密钥,使用xshell远程连接-其乐无穷资源网 - 自动架设游戏基地 | VM一键端 | 手游架设 | 端游架设 | GM
图片[6]-Centos 配置密钥,使用xshell远程连接-其乐无穷资源网 - 自动架设游戏基地 | VM一键端 | 手游架设 | 端游架设 | GM

3,到服务器上面认证公钥,上传刚刚保存的id_rsa_2048.pub 文件到服务器

[root@wscyun-com ~]# cat id_rsa_2048.pub >> .ssh/authorized_keys
[root@wscyun-com ~]# chmod 600 .ssh/authorized_keys 

4,使用xshell连接测试

图片[7]-Centos 配置密钥,使用xshell远程连接-其乐无穷资源网 - 自动架设游戏基地 | VM一键端 | 手游架设 | 端游架设 | GM
© 版权声明
THE END
喜欢就支持一下吧
点赞16 分享