Home >Create FTP user using SSH

Create FTP user using SSH

Before creating FTP user

In order to be able of creating a FTP user by SSH, there are two requirements you need to fullfill first which are preparing the server and configuring VSFTPD after that.

Server preparation

Servers are usually installed with ftp-server and ftp-client. But if the server is brand new, they also can be installed by commands. Here we use VSFTPD to setup ftp server.

  • As for Ubuntu:
sudo apt-get update
sudo apt-get install ftp
sudo apt-get install vsftpd
  • As for Centos:
sudo yum install vsftpd
sudo yum install ftp

VSFTPD Configuration

For Ubuntu, use sudo nano /etc/vsftpd.conf

For Centos, use sudo nano /etc/vsftpd/vsftpd.conf

After opening the file, we edit a few lines as listed followings:

  • Remove comment line 29 and 33
write_enable=YES
local_umask=022
  • Remove comment line 120 (in order to prevent access to the outside of that user’s Home directory)
chroot_local_user=YES
  •  Change pam_service_name=sftp to pam_service_name=ftp
  • Add allow_writeable_chroot=YES at the end of the file

Until now the configuration is considered to be finished. You just need to restart the service by using command sudo service vsftpd restart.

Create FTP user

In SSH we type:

useradd -d /path/to/user/home/directory/ -s /bin/bash -g groupname newusername

In which:

  • -d /path/to/user/home/directory/ is the server path to default directory as user connects to FTP server.
  • -s /bin/bash is command allowing an user to connect via SSH. If you don want that to be allowed, use /bin/false
  • -g groupname is to add new user to the group name “groupname”
  • newusername is just the name to sign in of the account we are creating 


To set password for new user:

passwd newusername

You will first be prompted to enter New UNIX password and Retype new UNIX password.
Now fill in the password twice (Command prompt will not move when you are typing). On successful password creation, there will be a notification like this:

passwd: all authentication tokens updated successfully.

Change FTP user

To replace the old username by a new one, just type this command

usermod -d /path/to/user/home/directory/ -s /bin/false – newusername

in which: all parameters are already explained in part 2 “Create FTP user”

Remove FTP user

To completely delete a FTP user, use userdel username.

If you want to delete home directory of user too, use userdel -r username.

< Previous Post
Next Post >
+ posts