I have a bizarre problem where ssh does not find a home directory for some users (that exists), yet the same user can login directly on my machine via a local terminal.
I maintain a server (server.domain.edu) where my students sftp in to submit homeworks/etc. The machine runs Fedora Linux 22. As an initial setup, I get them to ssh into the server and change their default password.
I set up their accounts with:
useradd -s /bin/changepasswd -p `openssl passwd -1 studentname` studentuname
changepasswd is a simple shell script that prints a few instructions, and calls on passwd. Permissions for
/bin/changepasswd is 755, and the owner:group are root:root
Now, I change ownership and group of /
home/studentname (to avoid problems with sftp).
ls -ld /home/studentname yields
drwxr-xr-x. 24 root teacher 4096 Jan 18 13:58 studentname
The mystery is that I created accounts for about a dozen students with exactly the same setup. For some of them, it works as expected (they log in, and the system runs changepasswd and the session terminates with the script). For the rest, the following happens:
ssh firstname.lastname@example.org Could not chdir to home directory /home/studentname: No such file or directory /bin/changepasswd: No such file or directory Connection to server.domain.edu closed.
On the other hand, if the same user who had a problem with ssh uses a local terminal on the server (the local text login), everything runs as expected without the above error messages. The ssh problem exists whether they use clients like putty/ssh command from mac or even ssh to the server from an xterm on the server (instead of directly logging in locally).
sshd_config has one thing out of ordinary---for every studentname I have:
Match Group studentname
Again, note that this actually works for some students but not others. The rest of the sshd_config file is the default one.
What could be going wrong?