ssh配置(免密码登录)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ssh配置(免密码登录)相关的知识,希望对你有一定的参考价值。

生成密钥:

[[email protected]_105 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory ‘/root/.ssh‘.
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:
7f:f3:89:77:41:73:ee:ea:1c:fe:19:ff:ad:23:b4:3e [email protected]_105
The key‘s randomart image is:
+--[ RSA 2048]----+
|                 |
|                 |
|                 |
|               o.|
|        S     ..o|
|         .  .  ..|
|          ..o..o.|
|           .E*ooB|
|           .o=OB*|
+-----------------+

查看:

[[email protected]_105 ~]# ll .ssh/
total 8
-rw-------. 1 root root 1675 Oct 23 06:52 id_rsa
-rw-r--r--. 1 root root  397 Oct 23 06:52 id_rsa.pub
[[email protected]_105 ~]# cd .ssh/

将公钥写入认证文件:

[[email protected]_105 .ssh]# cat id_rsa.pub >> authorized_keys

查看:

[[email protected]_105 .ssh]# ll
total 12
-rw-r--r--. 1 root root  397 Oct 23 06:54 authorized_keys
-rw-------. 1 root root 1675 Oct 23 06:52 id_rsa
-rw-r--r--. 1 root root  397 Oct 23 06:52 id_rsa.pub

赋予权限:

[[email protected]_105 .ssh]# chmod 644 authorized_keys
[[email protected]_105 .ssh]# ll
total 12
-rw-r--r--. 1 root root  397 Oct 23 06:54 authorized_keys
-rw-------. 1 root root 1675 Oct 23 06:52 id_rsa
-rw-r--r--. 1 root root  397 Oct 23 06:52 id_rsa.pub

模拟登录:

[[email protected]_105 .ssh]# ssh  CentOS_105
The authenticity of host ‘centos_105 (192.168.0.105)‘ can‘t be established.
ECDSA key fingerprint is 76:46:aa:90:04:2f:85:20:ee:a3:c9:1c:92:97:58:06.
Are you sure you want to continue connecting (yes/no)? y
Please type ‘yes‘ or ‘no‘: yes
Warning: Permanently added ‘centos_105,192.168.0.105‘ (ECDSA) to the list of known hosts.
Last login: Sun Oct 23 06:34:04 2016 from 192.168.0.103
[[email protected]_105 ~]# exit
logout
Connection to centos_105 closed.
[[email protected]_105 .ssh]#

第一次登录要输入yes/no确认连接.

以上是关于ssh配置(免密码登录)的主要内容,如果未能解决你的问题,请参考以下文章

配置免密码登录

有啥方法方便用SecureCRT免密码用ssh登录linux主机。

有啥方法方便用SecureCRT免密码用ssh登录linux主机。

ssh 免密码登录

有啥方法方便用SecureCRT免密码用ssh登录linux主机。

如何在linux中如何配置ssh免密码登录