请linux高手帮我啊,谢谢!
下面是我的步骤:
两个IP地址为 192.168.60.188,192.168.60.189
我是在192.168.60.188上面操作
步骤一:ssh-keygen -t rsa 不断回车
步骤二:进入.ssh/目录,看见文件会看见产生的
id_rsa和id_rsa.pub
步骤三:scp id_rsa.pub root@192.168.60.189:~/.ssh/authorized_keys
提示我连接上,而且输入密码,复制成功
步骤四:按理来说就可以了,我还是把防火墙关闭了,而且在192.168.60.189上,把authorized_keys
这个文件的权限 chmod +644 authorized_keys
步骤五:在192.168.60.188上面访问192.168.60.189
ssh 192.168.60.189
按理不需要密码,但是还是需要
请问大家,这个是怎么回事啊,我反复验证了N次了,每次都一样啊,求啊。。。。
11 个解决方案
#1
问题补充,两个用户都是用的root用户。。。
#2
再补充一下:
vi /etc/ssh/sshd_config
#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#RSAAuthentication yes
#PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
这两个配置文件都修改了,服务器和客户端都修改了。。。
vi /etc/ssh/sshd_config
#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#RSAAuthentication yes
#PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
这两个配置文件都修改了,服务器和客户端都修改了。。。
#3
你这个问题解决了吗?我也遇到同样的问题了。求答案
#4
下次直接ssh-copy-id方便
#5
求具体操作....
#6
使用下例中ssky-keygen和ssh-copy-id,仅需通过3个步骤的简单设置而无需输入密码就能登录远程Linux主机。
ssh-keygen 创建公钥和密钥。
ssh-copy-id 把本地主机的公钥复制到远程主机的authorized_keys文件上。
ssh-copy-id 也会给远程主机的用户主目录(home)和~/.ssh, 和~/.ssh/authorized_keys设置合适的权限 。
步骤1: 用 ssh-key-gen 在本地主机上创建公钥和密钥
ligh@local-host$ ssh-keygen -t rsa
Enter file in which to save the key (/home/jsmith/.ssh/id_rsa):[Enter key]
Enter passphrase (empty for no passphrase): [Press enter key]
Enter same passphrase again: [Pess enter key]
Your identification has been saved in /home/jsmith/.ssh/id_rsa.
Your public key has been saved in /home/jsmith/.ssh/id_rsa.pub.
The key fingerprint is: 33:b3:fe:af:95:95:18:11:31:d5:de:96:2f:f2:35:f9
ligh@local-host
步骤2: 用 ssh-copy-id 把公钥复制到远程主机上
ligh@local-host$ ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.0.3
ligh@remote-host‘s password:
Now try logging into the machine, with ―ssh ?remote-host‘‖, and check in:
.ssh/authorized_keys to make sure we haven‘t added extra keys that you weren‘t expecting.
[注: ssh-copy-id 把密钥追加到远程主机的 .ssh/authorized_key 上.]
步骤3: 直接登录远程主机
ligh@local-host$ ssh remote-host
Last login: Sun Nov 16 17:22:33 2008 from 192.168.1.2
[注: SSH 不会询问密码.]
ligh@remote-host$
[注: 你现在已经登录到了远程主机上
问题搞定...
#7
谢谢,正在为此纠结呢,
#8
发现本质原因是密钥文件的权限值必须设为600,感谢下liuyuanshijie
#9
~/.ssh权限值设为多少合适 。
#10
遇到同样的问题,密钥文件已经设置了600,也是用ssh-copy-id传过去的,可还是提示需要密码,求解
#11
多谢分享
#1
问题补充,两个用户都是用的root用户。。。
#2
再补充一下:
vi /etc/ssh/sshd_config
#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#RSAAuthentication yes
#PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
这两个配置文件都修改了,服务器和客户端都修改了。。。
vi /etc/ssh/sshd_config
#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#RSAAuthentication yes
#PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
这两个配置文件都修改了,服务器和客户端都修改了。。。
#3
你这个问题解决了吗?我也遇到同样的问题了。求答案
#4
下次直接ssh-copy-id方便
#5
求具体操作....
#6
使用下例中ssky-keygen和ssh-copy-id,仅需通过3个步骤的简单设置而无需输入密码就能登录远程Linux主机。
ssh-keygen 创建公钥和密钥。
ssh-copy-id 把本地主机的公钥复制到远程主机的authorized_keys文件上。
ssh-copy-id 也会给远程主机的用户主目录(home)和~/.ssh, 和~/.ssh/authorized_keys设置合适的权限 。
步骤1: 用 ssh-key-gen 在本地主机上创建公钥和密钥
ligh@local-host$ ssh-keygen -t rsa
Enter file in which to save the key (/home/jsmith/.ssh/id_rsa):[Enter key]
Enter passphrase (empty for no passphrase): [Press enter key]
Enter same passphrase again: [Pess enter key]
Your identification has been saved in /home/jsmith/.ssh/id_rsa.
Your public key has been saved in /home/jsmith/.ssh/id_rsa.pub.
The key fingerprint is: 33:b3:fe:af:95:95:18:11:31:d5:de:96:2f:f2:35:f9
ligh@local-host
步骤2: 用 ssh-copy-id 把公钥复制到远程主机上
ligh@local-host$ ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.0.3
ligh@remote-host‘s password:
Now try logging into the machine, with ―ssh ?remote-host‘‖, and check in:
.ssh/authorized_keys to make sure we haven‘t added extra keys that you weren‘t expecting.
[注: ssh-copy-id 把密钥追加到远程主机的 .ssh/authorized_key 上.]
步骤3: 直接登录远程主机
ligh@local-host$ ssh remote-host
Last login: Sun Nov 16 17:22:33 2008 from 192.168.1.2
[注: SSH 不会询问密码.]
ligh@remote-host$
[注: 你现在已经登录到了远程主机上
问题搞定...
#7
谢谢,正在为此纠结呢,
#8
发现本质原因是密钥文件的权限值必须设为600,感谢下liuyuanshijie
#9
~/.ssh权限值设为多少合适 。
#10
遇到同样的问题,密钥文件已经设置了600,也是用ssh-copy-id传过去的,可还是提示需要密码,求解
#11
多谢分享