Thursday, August 25, 2016

Install and configure sftp server on Ubuntu Server

Install VSFTPD 

sudo apt-get install vsftpd

Configuring VSFTPD.

open /etc/vftpd.conf file

Uncomment the following lines ;

write_enable=YES
local_umask=022 

chroot_local_user=YES  

Add the following line at the end of the file.

allow_writeable_chroot=YES


Now restart vsftpd.
Create a user for ftp and prevent use bash shell

sudo useradd -m john -s /usr/sbin/nologin
 sudo passwd john

Now open /etc/shells  file and add the following to the end of the file.

/usr/sbin/nologin

You can now connect using ftp to the server. But this is not protected. Any one can intercept with your traffic. You should use SSH FTP to secure the connection.

Install Open-SSH





sudo apt-get install openssh-server

Configure ssh to use in ftp.

For secure reason we should add a specific group for sshftp sessions. And add authorized users to that account.

sudo groupadd ftpgroup

sudo groupadd ftpuser


Configure ssh config file. 



Open /etc/ssh/sshd_config file,

Find the  Subsystem sftp .... line and edit it as follows
Subsystem sftp internal-sftp

And add the following to the end
Match group ftpgroup

For comprehensive understanding about sshd_config file type the following in terminal.
man sshd_conifg