User Tools

Site Tools


sftponlyuser

Setup user for SFTP access only

Scenario

  • give upload/download access to a single directory
  • no login
  • no escape from the directory
  • access the directory using your regular, privileged user

Step by step

  1. Choose an upload/download/“home” directory
    all components of the path must be owned by root and not writable by anyone else!
    For this example, let's assume /mnt/web/sftpuser
  2. adduser -r -s /usr/sbin/nologin --home /mnt/web/sftpuser --no-create-home sftpuser
  3. /etc/passwd should look like this:
    sftpuser:x:1002:1002::/mnt/web/sftpuser:/usr/sbin/nologin
  4. Set the password
    passwd sftpuser
  5. append a section like this to /etc/ssh/sshd_config:
    Match User sftpuser
            ChrootDirectory /mnt/web/sftpuser
            ForceCommand internal-sftp -u 0002
            X11Forwarding no
            AllowTcpForwarding no
  6. (optionally) Add your own user to the newly created user's group: usermod -aG sftpuser user
sftponlyuser.txt · Last modified: by wolfo

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki