I've created a user in Ubuntu and given them password auth access so they can login with ssh but i want to restrict their usage to a custom home folder located in:
/var/www/daniel (is a root folder with correct permissions)
/var/www/daniel/home (which is owned by daniel:daniel and 755 permissions)
In
/etc/ssh/sshd_config (i've enabled internal sftp)
Match User daniel
PasswordAuthentication yes
AllowTCPForwarding no
ForceCommand internal-sftp
ChrootDirectory %h
X11Forwarding no
restarted ssh service
then when i try to log in, i can see in the
auth.log
successful user login but it then kills the session based on this error
Accepted password for daniel ssh2
pam_unix(sshd:session): session opened for user daniel by (uid=0)
systemd-logind[508]: New session 63 of user daniel.
pam_unix(systemd-user:session): session opened for user daniel by (uid=0)
error: /dev/pts/2: No such file or directory
pam_unix(sshd:session): session closed for user daniel
Session 63 logged out. Waiting for processes to exit.
Any ideas?
UPDATE
i've executed the below from https://unix.stackexchange.com/questions/160461/chroot-gone-wrong-cant-ssh-with-user:
mount --bind /dev /var/daniel/dev
mount --bind /dev/pts /var/daniel/dev/pts
the error appears to be gone but it logs me straight out after auth
Accepted password for daniel
pam_unix(sshd:session): session opened for user daniel by (uid=0)
systemd-logind[508]: New session 130 of user daniel.
systemd: pam_unix(systemd-user:session): session opened for user daniel by (uid=0)
pam_unix(sshd:session): session closed for user daniel
systemd-logind[508]: Session 130 logged out. Waiting for processes to exit.