Advertisement
thesuhu

SFTP Server

Feb 4th, 2020
561
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.99 KB | None | 0 0
  1. # CREATE SFTP SERVER
  2.  
  3. # 1. SFTP Directory
  4. # create a directory that will house our FTP data
  5. mkdir -p /data
  6. chmod 701 /data
  7.  
  8. # 2. Create the SFTP group and user
  9. # Now we're going to create a special group for SFTP users
  10. groupadd sftp_users
  11.  
  12. # Now we're going to create a special user that doesn't have regular login privileges, but does belong to our newly created sftp_users group
  13. useradd -g sftp_users -d /upload -s /sbin/nologin sftpuser
  14.  
  15. # Next, give the new user a password
  16. passwd sftpuser (contoh password: usersftp)
  17.  
  18. # 3. Create the new user SFTP directory
  19. mkdir -p /data/sftpuser/upload
  20. chown -R root:sftp_users /data/sftpuser
  21. chown -R sftpuser:sftp_users /data/sftpuser/upload
  22.  
  23. # Configure sshd
  24. # Open up the SSH daemon configuration file
  25. vi /etc/ssh/sshd_config
  26.  
  27. # At the bottom of that file, add the following:
  28. Match Group sftp_users
  29. ChrootDirectory /data/%u
  30. ForceCommand internal-sftp
  31.  
  32. # Save and close that file. Restart SSH with the command:
  33. systemctl restart sshd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement