温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

linux下怎么设置ssh免密码登录

发布时间:2021-08-21 12:34:45 来源:亿速云 阅读:181 作者:chen 栏目:建站服务器

这篇文章主要介绍“linux下怎么设置ssh免密码登录”,在日常操作中,相信很多人在linux下怎么设置ssh免密码登录问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”linux下怎么设置ssh免密码登录”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

##linux7设置ssh免密码登录(密码变更后一样可以登录)
[root@rhel7 ~]$ ssh-keygen          #生产密钥文件
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
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:
32:a8:b6:60:58:9e:c4:fe:eb:9d:69:d5:ff:3f:d1:3a root@rhel7
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|                 |
|                 |
| .   .           |
|  + . o S.      .|
|.= o   o. .    ..|
|o.*    .   .   ..|
|.o o ..o    . E. |
|  ..+o+      ..oo|
+-----------------+

[root@rhel7 ~]$ ssh-copy-id 192.168.32.128                #复制到其他服务器
/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@192.168.32.128's password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '192.168.32.128'"
and check to make sure that only the key(s) you wanted were added. [root@rhel7 ~]$ ssh 192.168.32.128              #免密码登录
Last login: Mon Nov 20 22:30:47 2017 from 192.168.32.100
[root@mysql ~]# exit
logout
Connection to 192.168.32.128 closed.

[root@mysql ~]# passwd
Changing password for user root.
New password:
BAD PASSWORD: it is based on a dictionary word
Retype new password:
passwd: all authentication tokens updated successfully.

[root@rhel7 ~]$ ssh 192.168.32.128               #变更root密码后,还是可以免密码登录.
Last login: Mon Nov 20 22:32:35 2017 from 192.168.32.100                    

到此,关于“linux下怎么设置ssh免密码登录”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI