-2

I have a server which has a low storage problem. What i want is to mount the user ec2-user's home directory that is /home/ec2-user to another attached storage drive which is available at /dev/xvdk and its partitioned as xfs and the partition is /dev/xvdk1. So what i did is login as bob and rename /home/ec2-user to /etc/ec-user-backup/ and then rsync all files to the extra attached storage in /dev/xvdk1. Then mount that drive at /drive2. So now the c2-user's home directory is present at /drive2/ec2-user/. Now I create a symlink in /home/ec2-user which points to /drive2/ec2-user.

I also update the /etc/fstab accordingly. Check with mount -a. ec2-user's home directory has moved to new storage and is working.

The problem arises when i try to ssh in as ec2-user. The ssh key that was working previously has stopped working now. I have looked at the permissions on user's .ssh and all files under this and they seem to be alright. which is 600. Also im able to login in with password but not the ssh key.

What am i missing?

Saad Masood
  • 179
  • 3
  • 10
  • Check the server logs. – Jenny D Jan 01 '16 at 20:07
  • @JennyD which logs in specific. And what should I be looking for. – Saad Masood Jan 01 '16 at 21:38
  • If you don't know which logs then this isn't the site for your question. – user9517 Jan 01 '16 at 21:42
  • @Iain what are you suggesting? – Saad Masood Jan 02 '16 at 02:49
  • And yes I know which logs to look at but that shouldn't be the criteria for this question being valid for this site. – Saad Masood Jan 02 '16 at 02:55
  • 1
    The logs for the service you are trying and failing to connect to. In this case, sshd. And yes, knowing which logs to look at *is* part of the criteria for a question being valid on this site. See http://serverfault.com/help/how-to-ask for more information on that. – Jenny D Jan 02 '16 at 10:28
  • @JennyD thanks for the clarification of validity. The key is being rejected. I have a snapshot of the server prior to mounting and it works with same files. But not after mounting and symlinking. – Saad Masood Jan 02 '16 at 10:30
  • I've tried mounting the new drive on /home/ec2-user directly. No effect. – Saad Masood Jan 02 '16 at 10:33
  • I don't understand the downvotes. – Saad Masood Jan 02 '16 at 10:54
  • @lain is this clear enough? I have updated the question. – Saad Masood Jan 05 '16 at 19:53
  • I'm not sure why this question is closed. The question is clear and makes perfect sense to me. Today (December 2022) I ran into a similar problem with Fedora 37. I could no longer log in with `ssh` as a non-`root` user after I manually mounted a new `/home` partition. I could still `ssh` in as `root`. I suspected I was hitting a security policy of some kind. After some research, I tried disabling SELinux with `sudo setenforce 0`. Then I could log in again. (I am unfamiliar with SELinux, so I don't know the details of how SELinux is interacting with `sshd`.) – mpb Dec 20 '22 at 04:17

1 Answers1

2

The .ssh directory needs to have u+x permission set too

chmod u+x /home/ec2user/.ssh 
user9517
  • 115,471
  • 20
  • 215
  • 297