I have Ubuntu 16.04 server and i need to create a user account on the server which connect via sftp and must be restricted to one specific folder inside the Home directory.

I will need to use the public private key authentication for user to authenticate with server instead of password.

thats what i have done.

  • Created the User account.
  • created .ssh directory with inside the home directory of user.

mkdir -p ~/.ssh

  • copy the public key of the remote client which will be connecting my server inside the .ssh directory.
  • created the another Directory inside the home folder.

    mkdir -p ~/allowed-for-sftp-connection

  • and from the remote host i can easily make the connection to ubuntu server but with this connection i can as well see the content of .ssh directory which i don't want.

can someone please help me out , how can i get this task done.

  • You should use the Subsystem sftp internal-sftp option of SSH. Take a look at here and here. I have a smiliar setup. Just make sure that the groups and ownership are correct. – Robert Riedl Jan 24 '18 at 10:26
  • @RobertRiedl: thank you for your the links, I could manage to chroot the user to specific directory within the home directory but i still have issue with ssh key based authentication. – kunal Jan 24 '18 at 16:11

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.