在EC2托pipe的Ubuntu上,homedir权限和主机名更改后,SSH断开

我使用hostname实用程序更改了实例的主机hostname ,然后将其设置在/etc/hostname以便重新启动新名称。

我的主要动机是在PS1使用\h格式提示区分实例。

编辑我也改变了我的主目录的权限。 我使我的主目录组可写。

现在我不能再SSH进入机器。 它的缺点是Permission denied (publickey) 。 运行ssh -v ,更详细的输出是:

 debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Offering RSA public key: /Users/dmitry/.ssh/id_rsa debug1: Authentications that can continue: publickey debug1: Trying private key: /Users/dmitry/.ssh/ec2key.pem debug1: read PEM private key done: type RSA debug1: Authentications that can continue: publickey debug1: No more authentication methods to try. Permission denied (publickey). 

在更改主机名后我应该做些什么? 现在我无法进入实例! 🙁

谢天谢地,根挂载在EBS卷上运行。 所以,我能够通过停止实例并将EBS卷附加到另一个我正在运行的实例来debugging此问题。 然后我检查了/var/log/auth.log ,它提供了ssh -v没有提供的有用信息。 我注意到:

 Nov 26 02:55:39 myhost sshd[1746]: Authentication refused: bad ownership or modes for directory /home/myuser 

实际上,SSH并不开心,因为我已经给我的主目录写了perms,而/etc/ssh/sshd_config StrictModes被设置为yes

有关此问题的更多信息,请参阅http://recursive-design.com/blog/2010/09/14/ssh-authentication-refused/或通过在Web上searchSSH StrictModesAuthentication refused: bad ownership or modes for directory

你也应该改变/ etc / hosts