I am running my SSH server on a Debian build of Linux. When I connect to the server, I get access to the whole laptop's files. when I log int the file location I get access to is: '/home/myuser', but I want to change it so, when you log in to the server, I want there to be multiple users and each user has their own folder they can access and edit. An example of the server's folder would be: '/home/myuser/serverfolder' and within '/home/myuser/serverfolder' there would be a folder for each user.

How can I do what I explained above?

  • can you also add who will serve chroot dir? it is local or served from other central server with central server details. – asktyagi Jul 5 at 17:46
  • it's on a local server, but I'm accessing the server by typing in the IP address of the server/computer – Trevor Hummer Jul 5 at 17:48

In /etc/ssh/sshd_config file add this:

Match user myuser
  PasswordAuthentication yes
  ChrootDirectory /home/myuser/serverfolder
  X11Forwarding no
  AllowTcpForwarding no
  ForceCommand internal-sftp

Note that you also have change this:

Subsystem sftp /usr/lib/openssh/sftp-server

to this

Subsystem sftp internal-sftp

in the same /etc/ssh/sshd_config file.

And don't forget to restart ssh, after the changes are made: sudo service ssh restart

You should also make sure that the user owns the directory you want them to be able to access, but not parent directory:

sudo chown root:root /home/myuser/
sudo chown myuser:myuser /home/myuser/serverfolder -R
  • I've done all of that and nothing has changed when I access the server. Help? – Trevor Hummer Jul 6 at 2:09
  • I though you are connecting with sftp. Is that correct? – Ed Override Jul 7 at 4:12
  • Yes. Using SFTP on port 22 – Trevor Hummer Jul 7 at 23:31
  • Then this should work. Unless u connect via ssh.. – Ed Override Jul 8 at 8:26

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.