Merge pull request #2565 from KayGuoWhu/master

[Translated]20150323 How to enable ssh login without entering password
This commit is contained in:
Xingyu.Wang 2015-03-29 16:29:29 +08:00
commit 7cdc2b8cbd
2 changed files with 41 additions and 42 deletions

View File

@ -1,42 +0,0 @@
[translating by KayGuoWhu]
How to enable ssh login without entering password
================================================================================
Assume that you are a user "aliceA" on hostA, and wish to ssh to hostB as user "aliceB", without entering her password on hostB. You can follow this guide to **enable ssh login without entering a password**.
First of all, you need to be logged in as user "aliceA" on hostA.
Generate a public/private rsa key pair by using ssh-keygen. The generated key pair will be stored in ~/.ssh directory.
$ ssh-keygen -t rsa
Then, create ~/.ssh directory on aliceB account at the destination hostB by running the following command. This step can be omitted if there is already .ssh directory at aliceB@hostB.
$ ssh aliceB@hostB mkdir -p .ssh
Finally, copy the public key of user "aliceA" on hostA to aliceB@hostB to enable password-less ssh.
$ cat .ssh/id_rsa.pub | ssh aliceB@hostB 'cat >> .ssh/authorized_keys'
From this point on, you no longer need to type in password to ssh to aliceB@hostB from aliceA@hostA.
### Troubleshooting ###
1. You are still asked for an SSH password even after enabling key authentication. In this case, check for system logs (e.g., /var/log/secure) to see if you see something like the following.
Authentication refused: bad ownership or modes for file /home/aliceB/.ssh/authorized_keys
In this case, failure of key authentication is due to the fact that the permission or ownership ~/.ssh/authorized_keys file is not correct. Typically this error can happen if ~/.ssh/authorized_keys is read accessible to anyone but yourself. To fix this problem, change the file permission as follows.
$ chmod 700 ~/.ssh/authorized_keys
--------------------------------------------------------------------------------
via: http://xmodulo.com/how-to-enable-ssh-login-without.html
作者:[Dan Nanni][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://xmodulo.com/author/nanni

View File

@ -0,0 +1,41 @@
如何实现ssh无密码登录
================================================================================
假设你是hostA上的一个用户"aliceA"想以用户“aliceB”的身份ssh到hostB上但又不想输入密码。那么你可以参考这篇教程实现ssd无密码登录。
首先你需要以用户“aliceA”的身份登录到hostA上。
然后使用ssh-keygen生成一对rsa公私钥生成的密钥对会存放在~/.ssh目录下。
$ ssh-keygen -t rsa
接下来使用下面的命令在目标主机hostB上的aliceB用户目录下创建~/.ssh目录。如果在aliceB@hostB上已经存在.ssh目录这一步会被略过。
$ ssh aliceB@hostB mkdir -p .ssh
最后将hostA上用户“aliceA”的公钥拷贝到aliceB@hostB上来实现无密码ssh。
$ cat .ssh/id_rsa.pub | ssh aliceB@hostB 'cat >> .ssh/authorized_keys'
自此以后从aliceA@hostA上ssh到aliceB@hostB上再也不需要输入密码。
### 疑难解答 ###
1. 即使在密钥认证生效后你可能仍然需要输入SSH密码。如果遇到这种情况请检查系统日志如/var/log/secure以查看是否出现下面的异常。
Authentication refused: bad ownership or modes for file /home/aliceB/.ssh/authorized_keys
在这种情况下,密钥认证的失败是由于~/.ssh/authorized_keys文件的权限或拥有者不正确。一般情况如果这个文件对除了你之外的所有用户都可读就会出现这个错误。用下面的方式改变文件的权限以修正错误。
$ chmod 700 ~/.ssh/authorized_keys
--------------------------------------------------------------------------------
via: http://xmodulo.com/how-to-enable-ssh-login-without.html
作者:[Dan Nanni][a]
译者:[KayGuoWhu](https://github.com/KayGuoWhu)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://xmodulo.com/author/nanni