Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I change the home directory of my Amazon EC2 instance from /home/ubuntu to /home/ubuntu/folder in the /etc/passwd file, I am no longer able to access the instance using my existing keypair. Once I switch it back to the original directory I have no problems and can log into my instance as normal. I have checked the permissions on the new folder and they are drwxr-xr-x, which is the same the /home/ubuntu folder. I have a number of instances running at the minute and because of this change I have no way of logging back into them to rectify the situation. Does anyone have an idea what is going on?

share|improve this question
up vote 4 down vote accepted

You need to copy over the .ssh folder to the new home (which seems like you have, but reminding you anyway). You also have to make sure the the .ssh folder has the correct permissions (see below) on it if you are using StrictMode


Specifies whether sshd should check file modes and ownership of the user’s files 
and home directory before accepting login. This is normally desirable because novices 
sometimes accidentally leave their directory or files world-writable. The default is yes.

Permissions required for strict mode

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
share|improve this answer
Excellent, I copied the .ssh directory to the new directory. Thanks again. – Barry Jun 23 '11 at 15:28

Your Answer


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.