Saturday, December 16, 2017

SFTP on Ubuntu

https://askubuntu.com/questions/420652/how-to-setup-a-restricted-sftp-server-on-ubuntu


Step 1 : Install OpenSSH package if not installed

sudo apt-get install openssh-server

Step 2 : Create separate group for SFTP users.
 
sudo addgroup ftpaccess

Step 3 : Edit /etc/ssh/sshd_config file and make changes as below. Find and comment below line.
 
#Subsystem sftp /usr/lib/openssh/sftp-server

and add these lines to the end of the file.
 
Subsystem sftp internal-sftp 
 
Match group ftpaccess 
 
ChrootDirectory %h 
 
X11Forwarding no 
 
AllowTcpForwarding no 
 
ForceCommand internal-sftp

Step 4 : Restart sshd service.
 
sudo service ssh restart

Step 5 : Add user with ftpaccess group and create password.
 
sudo adduser paul --ingroup ftpaccess --shell /usr/sbin/nologin

Step 6 : Modify home directory permission.
 
sudo chown root:root /home/paul

Step 7 : Create a directory inside home for upload and modify permission with group.
 
sudo mkdir /home/paul/www
sudo chown paul:ftpaccess /home/paul/www

That's it .

Passwordless sftp

http://www.adminschoice.com/how-to-configure-ssh-without-password 

No comments:

Post a Comment