如何配置ssh服务使得不用输入账号密码即可连接远程主机


当前第2页 返回上一页

第一步也是生成秘钥对

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

# 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:

SHA256:GCyx2cSYE6yR7xCuUVOF0Omvp5fEoxv0Y2wOQvMRB98 root@lijia

The key's randomart image is:

+---[RSA 2048]----+

|  .*=Oo          |

|  * OX..         |

| o B=.* E        |

|. + o+ o         |

| ooooo. S        |

|.. +.+=          |

|  . ++*o         |

|   .o*+.         |

|    o=.          |

+----[SHA256]-----+

第二步,将刚生产的公钥传送给另一台机器

1

2

3

4

5

6

7

8

# ssh-copy-id root@121.***.***.64

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys

root@121.196.12.64's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'root@121.***.***.64'"

and check to make sure that only the key(s) you wanted were added.

第三步,登录远程主机

1

2

3

4

5

# ssh root@121.196.12.64

Welcome to Alibaba Cloud Elastic Compute Service !

Activate the web console with: systemctl enable --now cockpit.socket

Last login: Fri Nov 20 10:28:37 2020 from 111.38.123.86

# 免密码登录成功

更多相关技术文章,请访问linux系统教程栏目!

以上就是如何配置ssh服务使得不用输入账号密码即可连接远程主机的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

linux中SSH客户端断开后保持进程继续运行配置方法的具体介绍

SSH linux是什么

SSH无法连接centos7怎么办

ubuntu怎么开启SSH服务

linux如何安装SSH服务

如何使用SSH从服务器下载文件

linux中SSH远程登录失败怎么办

linux如何安装SSH服务

SSH linux是什么

什么是SSH,它是如何做到对信息进行加密操作的

更多相关阅读请进入《SSH》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...