SSH关于公钥认证Permission denied的问题

这两天在搭服务器的过程碰到一个问题,用户user的home目录:/home/user的权限变成了777,造成不能正常登陆SSH,报如下错误:Permission denied (publickey,gssapi-with-mic)



很明显是权限问题导致的,SSH对公钥、私钥的权限和所有权的要求是非常严格的,总结如下:

1、下面两个目录的所有权必须是user,所属组也应该是user,权限必须为700

\home\user

\home\user.ssh

2、下面公钥文件的所有权必须是user,所属组也应该是user,权限必须为644

\home\user.ssh\authorized_keys

3、下面私钥文件的所有权必须是user,所属组也应该是user,权限必须是600

\home\user.ssh\id_rsa



修改权限的指令名称 : chmod

语法为:chmod abc file

其中a,b,c各为一个数字,分别表示User、Group、及Other的权限。      

r=4,w=2,x=1   

  • 若要rwx属性则4+2+1=7;   
  • 若要rw-属性则4+2=6;   
  • 若要r-x属性则4+1=5。

比如:chmod 777 file

发布了82 篇原创文章 · 获赞 148 · 访问量 13万+
展开阅读全文

ssh登陆“Permission denied ”是怎么回事?

07-19

ssh登陆服务器,输入密码后却一直不能登陆进去,输出的调试信息是: ``` wangxiaoxiaodeMacBook-Air:.ssh wangxiaoxiao$ ssh -v -p 1029 xxwang@115.156.164.251 OpenSSH_6.9p1, LibreSSL 2.1.8 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 21: Applying options for * debug1: Connecting to 115.156.164.251 [115.156.164.251] port 1029. debug1: Connection established. debug1: identity file /Users/wangxiaoxiao/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /Users/wangxiaoxiao/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/wangxiaoxiao/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/wangxiaoxiao/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/wangxiaoxiao/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/wangxiaoxiao/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/wangxiaoxiao/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /Users/wangxiaoxiao/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.9 debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3 debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3 pat OpenSSH_6.6.1* compat 0x04000000 debug1: Authenticating to 115.156.164.251:1029 as 'xxwang' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client chacha20-poly1305@openssh.com <implicit> none debug1: kex: client->server chacha20-poly1305@openssh.com <implicit> none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ecdsa-sha2-nistp256 SHA256:hEan0tTVdOIgIhYZnv9cee++XRQXxts3RWehu5+cDis debug1: Host '[115.156.164.251]:1029' is known and matches the ECDSA host key. debug1: Found key in /Users/wangxiaoxiao/.ssh/known_hosts:1 debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey,password debug1: Next authentication method: publickey debug1: Offering RSA public key: /Users/wangxiaoxiao/.ssh/id_rsa debug1: Authentications that can continue: publickey,password debug1: Trying private key: /Users/wangxiaoxiao/.ssh/id_dsa debug1: Trying private key: /Users/wangxiaoxiao/.ssh/id_ecdsa debug1: Trying private key: /Users/wangxiaoxiao/.ssh/id_ed25519 debug1: Next authentication method: password xxwang@115.156.164.251's password: debug1: Authentications that can continue: publickey,password Permission denied, please try again. xxwang@115.156.164.251's password: debug1: Authentications that can continue: publickey,password Permission denied, please try again. xxwang@115.156.164.251's password: debug1: Authentications that can continue: publickey,password debug1: No more authentication methods to try. Permission denied (publickey,password).``` ``` 然后我谷歌了一下,按照网上的方法,把.ssh删了,再重新ssh-keygen重新生成,后再ssh,依然存在这个同样的问题? 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 编程工作室 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览