Authentication CentOS中非root用户的ssh密钥配置

Authentication CentOS中非root用户的ssh密钥配置,authentication,ssh,centos,rsa,Authentication,Ssh,Centos,Rsa,服务器操作系统:CentOS 6.6 我想为名为otheruser的非root用户进行无密码登录。 我处理的步骤如下: I.在服务器中生成公钥和私钥: [otheruser@localhost ~]# ssh-keygen -t rsa 我接受默认设置,然后将.ssh/id\u rsa.pub重命名为授权密钥 [otheruser@localhost ~/.ssh]# cp id_rsa.pub authorized_keys [otheruser@localhost ~/.ssh]# ls

服务器操作系统:CentOS 6.6

我想为名为otheruser的非root用户进行无密码登录。 我处理的步骤如下:

I.在服务器中生成公钥和私钥:

[otheruser@localhost ~]# ssh-keygen -t rsa
我接受默认设置,然后将
.ssh/id\u rsa.pub
重命名为
授权密钥

[otheruser@localhost ~/.ssh]# cp id_rsa.pub authorized_keys
[otheruser@localhost ~/.ssh]# ls -al ~
drwx------  2 otheruser otheruser 4096 May 13 06:50 .ssh
[otheruser@localhost ~/.ssh]# ls -al ~/.ssh
drwx------  2 otheruser otheruser 4096 May 13 06:50 .
drwxrwxr--. 4 otheruser otheruser 4096 May  9 07:23 ..
-rw-------  1 otheruser otheruser  412 May 13 06:50 authorized_keys
-rw-------  1 otheruser otheruser 1675 May 13 06:48 id_rsa
-rw-------  1 otheruser otheruser  412 May 13 06:48 id_rsa.pub
可以注意到,
/home/otheruser/.ssh
的权限是700,
/home/otheruser/.ssh/authorized_key
的权限是600,两者都属于uesr
otheruser
和组
otheruser

二,。修改/etc/ssh/sshd\u配置

添加配置:

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile    .ssh/authorized_keys
AllowUsers otheruser
重新启动sshd服务:

[root@localhost ~]# service sshd restart
Stopping sshd:                                             [  OK  ]
Starting sshd:                                             [  OK  ]
我将私钥从服务器复制到本地计算机。并尝试使用ssh连接到服务器:

ssh -i id_rsa otheruse@192.168.1.101
但我收到一个
权限被拒绝的提示:

Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
/var/log/secure
中的记录是:

May 12 07:07:08 localhost sshd[1230]: Connection closed by 192.168.1.1
May 12 07:07:14 localhost sshd[1231]: Authentication refused: bad ownership or modes for directory /home/otheruser

我不知道我有什么问题。有人能帮我吗QAQ

哦,我通过引用这个链接来解决我的问题

我要做的是更改
/home/otheruser

[root@localhost ~] chmod go-w otheruser

但是我仍然不明白导致这个问题的原因。

你能理解吗?@sajib khan我的问题似乎没有受到影响。服务器中的
getenforce
结果在sshd中被
禁用
,用户折叠的权限不应该被其他人写入?