Linux SSH配置了免密码登录,登录时还要输入密码
[mon@oracle6 ~]$ ll .ssh
ls: cannot access .ssh: No such file or directory
[mon@oracle6 ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/mon/.ssh/id_rsa):
Created directory '/home/mon/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/mon/.ssh/id_rsa.
Your public key has been saved in /home/mon/.ssh/id_rsa.pub.
The key fingerprint is:
5c:0e:06:09:64:aa:ae:47:1d:9e:11:e9:58:d8:9c:36 mon@oracle6
The key's randomart image is:
+--[ RSA 2048]----+
| =++.. |
| .oE .. |
| .= o o . |
| .. + o + |
|. o + S . |
|. . + |
| o |
|. . |
|.. |
+-----------------+
[mon@oracle6 ~]$ ll .ssh
total 12
-rw-------. 1 mon mon 1675 Feb 21 17:16 id_rsa
-rw-r--r--. 1 mon mon 393 Feb 21 17:16 id_rsa.pub
-rw-r--r--. 1 mon mon 401 Feb 21 17:17 known_hosts
[mon@oracle6 ~]$ ssh mon@topaz "cat >> ~/.ssh/authorized_keys" < ~/.ssh/id_rsa.pub
The authenticity of host 'oracle (172.16.99.19)' can't be established.
RSA key fingerprint is b6:9f:be:8a:ad:1e:e8:c8:1f:b4:75:04:01:69:0e:5e.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'oracle,172.16.99.19' (RSA) to the list of known hosts.
mon@topaz's password: mon
[mon@oracle6 ~]$ ssh mon@topaz
mon@topaz's password:
ssh mon@topaz还需要输入密码。
baidu之后发现topaz服务器上,的authorized_keys属性(664)有问题,应该为600
authorized_keys的正确属性为600
.ssh的正确属性为700
[mon@topaz ~]$ ll -a
drwx------ 2 mon mon 4096 Feb 21 19:13 .ssh
[mon@topaz .ssh]$ ll
total 12
-rw-rw-r-- 1 mon mon 1179 Feb 21 19:16 authorized_keys
-rw------- 1 mon mon 1675 Feb 21 19:12 id_rsa
-rw-r--r-- 1 mon mon 391 Feb 21 19:12 id_rsa.pub
修改authorized_keys的属性为600
[mon@topaz .ssh]$ chmod 600 authorized_keys
之后ssh mon@topaz可以正常登录。
[mon@oracle6 ~]$ ssh mon@topaz
Last login: Sun Feb 21 19:17:49 2016 from s-file-backend.domain.com
[mon@oracle6 ~]$ echo "df -P" | ssh mon@topaz
Pseudo-terminal will not be allocated because stdin is not a terminal.
Filesystem 1024-blocks Used Available Capacity Mounted on
/dev/sda2 14877092 5685340 8423848 41% /
/dev/sda5 62216440 52317664 6687388 89% /u01
/dev/sda1 101086 11885 83982 13% /boot
tmpfs 4194304 1063292 3131012 26% /dev/shm
/dev/sdc1 82567188 705556 77667464 1% /u02
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24237320/viewspace-1994776/
,如需转载,请注明出处,否则将追究法律责任。