2

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.

Details follow:

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 studentname@server.domain.edu

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 file:

sshd_config has one thing out of ordinary---for every studentname I have:

Match Group studentname
ForceCommand /bin/changepasswd
ChrootDirectory /home/studentname
PermitTunnel no
AllowAgentForwarding no
X11Forwarding no
AllowTcpForwarding no

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?

  • 1
    What Linux/OS? What interesting is in sshd_config? – Jakuje Jan 19 '17 at 7:42
  • If it's Linux what does the SSH daemon tell you during logon (/var/log/auth on Debian; may be elsewhere on RH derived systems) – roaima Jan 19 '17 at 8:08
  • The server runs Fedora linux 22. sshd_config has one thing out of ordinary---for every studentname I have: Match Group studentname ForceCommand /bin/changepasswd ChrootDirectory /home/studentname PermitTunnel no AllowAgentForwarding no X11Forwarding no AllowTcpForwarding no – Pr-San Jan 19 '17 at 21:01
  • 1
    The ChrootDirectory /home/studentname would explain /bin/changepasswd: No such file or directory Unless every student has a /home/studentname/bin/changepasswd. – ctrl-alt-delor Jan 19 '17 at 21:24
  • read the logs, on server and run ssh in debug mode, to get client side logs. – ctrl-alt-delor Jan 19 '17 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.