Search code examples
sshdebianopensshchroot

User gets instantly disconnected after connection successful on a chrooted SSH


I configured a jail with Chroot in SSH following this tutorial.

I found another question on StackOverflow dealing with the same problem, however the answers didn't work for me either.

The auth.log file contains the following:

Mar 16 18:36:06 *** sshd[30509]: Accepted password for thenewone from x.x.x.x port 49583 ssh2
Mar 16 18:36:06 *** sshd[30509]: pam_unix(sshd:session): session opened for user thenewone by (uid=0)
Mar 16 18:36:07 *** sshd[30509]: lastlog_openseek: Couldn't stat /var/log/lastlog: No such file or directory
Mar 16 18:36:07 *** sshd[30509]: lastlog_openseek: Couldn't stat /var/log/lastlog: No such file or directory
Mar 16 18:36:07 *** sshd[30509]: pam_unix(sshd:session): session closed for user thenewone

My sshd_config file contains the following:

Match User thenewone
    ChrootDirectory         /home/thenewone
    AllowTcpForwarding      no
    X11Forwarding           no

My /home/thenewone directory is owned by root:root and contains the chrooted system (all files but /home/thenewone/home/thenewone owned by root:root)

I don't understand why the connection is successful then simply close.


Solution

  • Problem found: some binaries dependencies were missing, even for the shell associated with the chrooted account...

    Shell failed to load --> disconnection!

    If you are experiencing the same trouble as mine, use ldd <binary> to find all needed dependencies in the chroot jail