How to create an SFTP client for AWS Ubuntu server ?

How to create an SFTP client for AWS Ubuntu server ?

November 18, 2020 / Eternal Team

What is the use of SFTP?

SFTP (SSH File Transfer Protocol, also known as Secure FTP) is a popular method for securely transfer of files to/from remote systems. SFTP was designed as an extension of the Secure Shell protocol (SSH) version 2.0 to enhance secure file transfer capabilities.

How to set-up SFTP in the AWS Ubuntu server

Per-requisites

  • AWS account
  • EC2 Ubuntu Server

Step 1

how-to-create-an-sfpt-client-for-aws-ubuntu-server

Step 2

Connect to your server

how-to-create-an-sfpt-client-for-aws-ubuntu-server

Step 3

Update and upgrade your server to get the latest packages

$ sudo apt update && sudo apt upgrade -y

how-to-create-an-sfpt-client-for-aws-ubuntu-server

Step 4

Install apache2 as we are going to give access to SFTP of HTML folder only

$ sudo apt install apache2 -y

how-to-create-an-sfpt-client-for-aws-ubuntu-server

Step 5

Now add a new user ( In our case, we have given name sftptestuser )

$ sudo adduser sftptestuser

how-to-create-an-sfpt-client-for-aws-ubuntu-server

Create a password to access the user via FTP/sFTP client

how-to-create-an-sfpt-client-for-aws-ubuntu-server

Optional Fill all the details and the press y and press ENTER

how-to-create-an-sfpt-client-for-aws-ubuntu-server

Step 6

Add the file path in front of the username by editing in /etc/passwd file

$ sudo vim /etc/passwd

how-to-create-an-sfpt-client-for-aws-ubuntu-server

As you can see in the last line

how-to-create-an-sfpt-client-for-aws-ubuntu-server

how-to-create-an-sfpt-client-for-aws-ubuntu-server

Step 7

Edit the /etc/ssh/sshd_config to allow the access the user via password

$ sudo vim /etc/ssh/sshd_config

how-to-create-an-sfpt-client-for-aws-ubuntu-server

Add the below line to the end of the config file as you can see in the image

$ Match User
$ PasswordAuthentication yes

how-to-create-an-sfpt-client-for-aws-ubuntu-server

Step 8

Navigate to the /var/www

$ cd /var/www

how-to-create-an-sfpt-client-for-aws-ubuntu-server

Step 9

Change the ownership of the HTML to be accessible to the sFTP user

$ sudo chown -R ftpusername:www-data html

how-to-create-an-sfpt-client-for-aws-ubuntu-server

Step 10

Go inside the HTML folder and paste the command as under

$ cd /var/www/html

how-to-create-an-sfpt-client-for-aws-ubuntu-server

$ sudo find . -type d -exec chmod -R 775 {} \;

how-to-create-an-sfpt-client-for-aws-ubuntu-server

$ sudo find . -type f -exec chmod -R 664 {} \;

how-to-create-an-sfpt-client-for-aws-ubuntu-server

Step 11

Go to /var/www and paste the command this will change the ownership of every file that is in the folder HTML

$ cd /var/www

how-to-create-an-sfpt-client-for-aws-ubuntu-server

$ sudo chmod -R ugo+s html

how-to-create-an-sfpt-client-for-aws-ubuntu-server

Step 12

Now restart the sshd service to implement the changes we have done

$ sudo service sshd restart

how-to-create-an-sfpt-client-for-aws-ubuntu-server

Step 13

As you can see in all the above steps we have configured the sFTP user now we will try to connect to the user via FTP/SFTP

  • Protocol:- Public_IP
  • User :- sftpusername
  • Password:- yourselectedpassword

how-to-create-an-sfpt-client-for-aws-ubuntu-server

As you can see /var/www/html is listed in the image

how-to-create-an-sfpt-client-for-aws-ubuntu-server

AWS-Consulting-Partner

Talk to AWS Certified Consultant

    Want to start a project?

    It’s simple.

    Contact us