Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I changed my instance's hostname using the hostname utility and then set it in /etc/hostname so that the new name survives reboot.

My main motivation was for differentiating between instances at the prompt using the \h format in PS1.

EDIT I also changed permissions on my home directory. I made my home directory group writeable.

Now I can no longer SSH into the machine. The short of it is the error Permission denied (publickey). Running ssh -v, the more verbose output is:

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).

Should I have done something after changing the hostname? Now I can't get into the instance! :(

share|improve this question
2  
"I made my home directory group writeable." - did you do that recursively, including the .ssh directory? If so, that makes OpenSSH daemon refuse your login using public key. –  gertvdijk Nov 26 '12 at 8:06
    
Actually, @gertvdijk, I did not! I left the .ssh read/writeable to me, only. It appears that SSH doesn't like it even when ~ is group writeable, please see my answer below! –  dimadima Nov 26 '12 at 15:57
1  
good catch, good answer. Hope my comment was of any help anyway. :) –  gertvdijk Nov 26 '12 at 16:12
    
It turned out that I resolved the problem before your post, but couldn't answer my own question before waiting some time due to serverfault.com regulations on answering your own question (8 hours must elapse if your rating is low). Your comment would have definitely put me on the right track had I not resolved the issue! Thank you! –  dimadima Nov 26 '12 at 18:28

2 Answers 2

You should have changed /etc/hosts too

share|improve this answer
    
I added 127.0.0.1 newhostname to my /etc/hosts too, actually. Something else I should have changed? –  dimadima Nov 26 '12 at 0:08
    
added or changed? On a default Ubuntu install it's already in there, so you need to change it instead of adding to it. –  Dennis Kaarsemaker Nov 26 '12 at 0:13
    
I added it. As I recall, there was only 127.0.0.1 localhost and some IPV6 enteries in the /etc/hosts, so nothing to edit really. It's not like there was a 127.0.0.1 oldhostname entry. –  dimadima Nov 26 '12 at 0:21
up vote 1 down vote accepted

Thankfully the root mount was running on an EBS volume. So, I was able to debug this issue by stopping the instance and attaching the EBS volume to another instance I had running. I then examined /var/log/auth.log, which provided the useful information ssh -v was not providing. I noticed:

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

Indeed, SSH was not happy that I had given group write perms to my home directory, while StrictModes was set to yes in /etc/ssh/sshd_config.

More information on this issue can found at http://recursive-design.com/blog/2010/09/14/ssh-authentication-refused/ or by searching the Web for SSH StrictModes or Authentication refused: bad ownership or modes for directory.

share|improve this answer
    
How you solved the issue ? How can you change the permission if you don't have access to ssh ? –  Jashwant Nov 8 '13 at 8:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.