FTP – TecAdmin https://tecadmin.net How to guide for System Administrator's and Developers Fri, 05 Aug 2022 12:27:08 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 How To Setup FTP Server with VSFTPD on Ubuntu 20.04 https://tecadmin.net/how-to-setup-vsftpd-on-ubuntu-20-04/ https://tecadmin.net/how-to-setup-vsftpd-on-ubuntu-20-04/#respond Thu, 15 Jul 2021 09:46:37 +0000 https://tecadmin.net/?p=22749 FTP (File Transfer Protocol) is a network transmission standard that is used to transfer data from client to server and vice versa. It uses TCP (Transmission Control Protocol) which ensures that the data is actually arriving at its destination. TCP is what makes FTP reliable. FTP is very helpful for businesses as it allows them [...]

The post How To Setup FTP Server with VSFTPD on Ubuntu 20.04 appeared first on TecAdmin.

]]>
FTP (File Transfer Protocol) is a network transmission standard that is used to transfer data from client to server and vice versa. It uses TCP (Transmission Control Protocol) which ensures that the data is actually arriving at its destination. TCP is what makes FTP reliable.

FTP is very helpful for businesses as it allows them to perform important functions such as the transfer of large and bulky files on a routine basis. These activities cannot be done over email or through other basic file-sharing programs. It is also used to upload and manage website files to the server.

The FTP is still a very popular way for transferring files but due to the security regions, many peoples prefer SFTP. Use this article to create SFTP only users without shell access.

In this write-up, we will be focusing on how to set up an FTP server with VSFTPD on Ubuntu 20.04.

Installing vsftpd on Ubuntu

VSFTPD is the default FTP server for most Linux distributions. We will start off by installing it on our system. Use the command given below to install VSFTPD.:

sudo apt update 
sudo apt install vsftpd 

installing vsftpd ubuntu 20.04

Now verify the successful installation of VSFTPD by executing the following command:

sudo systemctl status vsftpd 

check vsftpd service status

How to Configure vsftpd on Ubuntu

Now we will configure the newly installed vsftpd. The configuration rules of vsftpd are stored in /etc/vsftpd.conf. Open the configuration file in any text editor. Here we will use nano to open the configuration file:

sudo nano /etc/vsftpd.conf 

Update the following configuration settings:

  1. FTP access

    To only allow local users to access FTP server, make sure your configuration file matches the one given below:

    anonymous_enable=NO
    local_enable=YES
    
  2. FTP Passive connections

    VSFTPD works on the active mode by default. To allow VSFTPD to work on passive mode copy the below-given lines into your configuration file:

    pasv_min_port=40000
    pasv_max_port=45000
    

    You can give any range of ports to the configuration file. The system will connect a random port from the range you’ve chosen.

    The connection is established by the server in active mode whereas in the passive mode the connection is established by the client’s side.

  3. Enable Uploads

    To allow the FTP user to modify the filesystem, search for the following line in the configuration file and uncomment it by removing the ‘#’ (hash) symbol from the beginning of the line:

    write_enable=YES
    
  4. Restrict FTP access

    To allow only certain users to access VSFTPD, copy the below given lines at the end of the configuration file:

    userlist_enable=YES
    userlist_file=/etc/vsftpd.user_list
    userlist_deny=NO
    

These configuration settings are very basic. You can set the configuration rules according to your own needs.

Press Ctrl + X and then hit Enter to save and exit the text file. Now run the following command to restart the VSFTPD service:

sudo systemctl restart vsftpd 

How to Configure the Firewall For FTP on Ubuntu

Now we will configure the firewall to allow FTP traffic. We will open ports 20 and 21, the default/recommended ports for FTP, and ports 40000:45000 for passive FTP. But first, let’s allow SSH by using the command given below otherwise we may get locked out of our server:

sudo ufw allow OpenSSH 

If you get an error “ERROR: Could not find a profile matching ‘OpenSSH’” then you first need to install OpenSSH before running the above command. Use the following command to install OpenSSH on your system:

sudo apt install ssh

Once everything is set up, open the default ports 20 and 21 for FTP:

sudo ufw allow 20:21/tcp

Open the ports 40000:45000 for passive FTP as well:

sudo ufw allow 40000:45000/tcp

Now run the firewall by using the following command. Ignore, if it gives a warning about the disruption of SSH connection. Press y and hit Enter:

sudo ufw enable

The firewall is already active and enabled on my system.

You may run the following command to verify the firewall rules that were just added:

sudo ufw status

UFW Allow FTP

How to Create a user for FTP on Ubuntu

Use the “adduser” command to create a new user. We will use this user to login into FTP.

sudo adduser test_user 

The terminal will ask you to set the password of the new user. It will also ask for a few other details. Just press Enter if you do not want to provide these details.

You can restrict this user’s SSH access if you only want them to log in through FTP. Use the nano editor to open the SSH configuration files:

sudo nano /etc/ssh/sshd_config 

Now copy the following line and paste it into the configuration file to restrict the users access:

DenyUsers test_user

vsftpd deny specific user

(Do remember to replace “test_user” with the actual name of your user)

Save and exit the configuration file and reboot the SSH service using the below-given command to let the changes take effect:

sudo systemctl restart ssh

Now add the user to the list of FTP users by running the following command:

echo "test_user" | sudo tee -a /etc/vsftpd.user_list

Next make a new directory for the user to use for uploading the files:

sudo mkdir -p /home/test_user/ftp/test_dir 

Now give permissions to the new user according to your requirements. Here we are giving the following permission to the test_user:

sudo chmod 550 /home/test_user/ftp 
sudo chmod 750 /home/test_user/ftp/test_dir 
sudo chown -R test_user: /home/test_user/ftp 

Here 550 gives the “read” and “execute” permission in the following way:

chmod 550 permissions

While 750 gives the “write” permission as well to the owner in the following way:

chmod 750 permissions

That’s it. Your FTP server has been fully set up.

Conclusion

FTP is used to transfer files between computers on a network. It is a protocol that dictates (instructs) how data is transferred between computers on the network. People still use FTB but it is not as secure as SCP or SFTP.

In this write-up, we focused on how to install, set up, and configure VSFTPD. Moreover, we comprehended how to configure firewalls and create a new user for FTP.

You may also like another tutorial, how to download and upload files using ftp command line.

The post How To Setup FTP Server with VSFTPD on Ubuntu 20.04 appeared first on TecAdmin.

]]>
https://tecadmin.net/how-to-setup-vsftpd-on-ubuntu-20-04/feed/ 0
How to Download and Upload Files with SFTP Securely https://tecadmin.net/download-and-upload-files-with-sftp/ https://tecadmin.net/download-and-upload-files-with-sftp/#comments Wed, 08 Mar 2017 18:31:41 +0000 https://tecadmin.net/?p=11602 SFTP (SSH File Transfer Protocol) is secured protocol to transfer files between local and remote server. To required SSH server running on the remote system. This protocol encrypts the transfer of data between local and remote system. As SFTP provides secure data transfer, so we recommend it over FTP protocol. SFTP is recommended but in [...]

The post How to Download and Upload Files with SFTP Securely appeared first on TecAdmin.

]]>
SFTP (SSH File Transfer Protocol) is secured protocol to transfer files between local and remote server. To required SSH server running on the remote system. This protocol encrypts the transfer of data between local and remote system. As SFTP provides secure data transfer, so we recommend it over FTP protocol.

SFTP is recommended but in case you only have the FTP server running on remote, use below link for FTP access.

Connect to SFTP Server:

SFTP connects to ssh server. You must have the ssh server running on the remote system. Use the following command to connect example.com server as user rahul.

$ sftp rahul@example.com

to connect with different port

$ sftp -P 2222 rahul@example.com

After successful authentication, you will get a sftp prompt. Where you can download or upload files securely. To get available commands type help on sftp prompt.

sftp> help 

Available commands:
bye                         Quit sftp
cd path                     Change remote directory to 'path'
chgrp grp path              Change group of file 'path' to 'grp'
chmod mode path             Change permissions of file 'path' to 'mode'
chown own path              Change owner of file 'path' to 'own'
df [-hi] [path]             Display statistics for current directory or
...
...

Change Local and Remote Directory

First check your local and remote server directory using following commands.

sftp> !pwd
/home/ubuntu

sftp> pwd
/home/rahul
  • !pwd – Used to check current directory on local system
  • pwd – Used to check current directory on remote system

Now navigate between directories on local and remote sftp system.

sftp> lcd /home/ubuntu/Downloads

sftp> cd Uploads
  • lcd – Used to navigate between directories on local system
  • cd – Used to navigate between directories on remote system

Download Files from SFTP

Use get command to download file from sftp server to local system drive. Use lcd to change location of local download folder. Below command will download remotefile.txt from remote system to local system.

sftp> get remotefile.txt

To download files and folders recursively use -r switch with get command. Below command will download folder remotedir from remote system to local system recursively.

sftp> get -r remotedir

Upload Files to SFTP

Use put command to upload a file from local system to remote system. Use cd to change location of remote upload folder first. the below command will upload localfile.txt from local system to remote sftp system.

sftp> put localfile.txt

To upload files and folders recursively use -r switch with put command. Below command will upload directory localdir and all files and sub directories to remote server.

sftp> put -r localdir

The post How to Download and Upload Files with SFTP Securely appeared first on TecAdmin.

]]>
https://tecadmin.net/download-and-upload-files-with-sftp/feed/ 1
How to Recursively Download Files from FTP https://tecadmin.net/recursively-download-files-from-ftp/ https://tecadmin.net/recursively-download-files-from-ftp/#respond Thu, 14 Apr 2016 13:52:08 +0000 https://tecadmin.net/?p=10072 You can download complete website recursively using wget command line utility. wget is a frequently used command for downloading files from http and ftp servers. In this tutorial you will learn how to Recursively Download Files from FTP. For example – below command will download /remote/dir directory and its subdirectory from example.com ftp server. $ [...]

The post How to Recursively Download Files from FTP appeared first on TecAdmin.

]]>
You can download complete website recursively using wget command line utility. wget is a frequently used command for downloading files from http and ftp servers. In this tutorial you will learn how to Recursively Download Files from FTP.

For example – below command will download /remote/dir directory and its subdirectory from example.com ftp server.

$ wget -r ftp://ftpuser:password@example.com/remote/dir/

You can define username and password for authenticated ftp server like below example command.

$ wget -r --user="ftpuser" --password="password" ftp://example.com/subdir/

Additional Parameters
You may used some additional parameters to wget command to use more features in files downloading.

–reject jpg,png – To exclude jpg and png files from downloading.
-nH – avoids the creation of a directory named after the server name
-nc – avoids creating a new file if it already exists on the destination (it is just skipped)

The post How to Recursively Download Files from FTP appeared first on TecAdmin.

]]>
https://tecadmin.net/recursively-download-files-from-ftp/feed/ 0
How to Download and Upload Files using FTP Command Line https://tecadmin.net/download-upload-files-using-ftp-command-line/ https://tecadmin.net/download-upload-files-using-ftp-command-line/#comments Sat, 04 Apr 2015 08:00:57 +0000 https://tecadmin.net/?p=4640 FTP (File Transfer Protocol) is the most popular protocol to transfer files (download and upload) from one system to another system. It provides the fastest way to transfer files. There is much application available on Linux and windows to FTP services like vsFTPd, proFTPd for Linux, FileZilla Server for windows. There are various ways to [...]

The post How to Download and Upload Files using FTP Command Line appeared first on TecAdmin.

]]>
FTP (File Transfer Protocol) is the most popular protocol to transfer files (download and upload) from one system to another system. It provides the fastest way to transfer files. There is much application available on Linux and windows to FTP services like vsFTPd, proFTPd for Linux, FileZilla Server for windows.

There are various ways to connect to the FTP server, Also you can find multiple free tools on the internet to work with FTP. But system admins know the power of command line. This article will help you to how to connect to the FTP server using the command line and Download and Upload Files using FTP protocol between the FTP server local system.

Remember that FTP is not a secure protocol. We recommend using SFTP for transferring files security. Visit below links to how to use SFTP.

1. Connect to FTP Server via Command Line

To connect to any FTP server from windows open its command prompt and for Linux open terminal window. Now you have required IP or Hostname of FTP server and login credentials to connect with a specific user.

c:\> ftp ftp.tecadmin.net

Download and Upload Files using FTP

2. Upload Single File to FTP Server

To upload file on FTP server use put command from FTP prompt. First, navigate to the desired directory on the FTP server where to upload a file and use the following command. It will upload local system file c:\files\file1.txt to uploads directory on FTP server.

ftp> cd uploads
ftp> put c:\files\file1.txt

Download and Upload Files using FTP

3. Download A Single File from FTP

To download the file from FTP server, we use get command. Using that command we can download one time at a time. To download any file from FTP server First login to your FTP server, navigate to the directory and use the following command to download

ftp> get file1.txt

Download and Upload Files using FTP

4. Upload Multiple Files to FTP

To upload multiple files to FTP server use mput command. You can also specify wildcard characters to upload multiple files to the server at a time. First, navigate to the desired directory on the FTP server where to upload a file and use the following command. It will upload local system files with .txt extension in c:files directory to uploads directory on FTP server.

ftp> cd uploads
ftp> lcd c:\\files

ftp> put *.txt

Download and Upload Files using FTP

5. Download Multiple Files from FTP

To download multiple files from FTP server, we use mget command. Using that command we can download more than one file at a time. To download multiple files specify wildcard character for specifying directory name do download all files from the directory.

ftp> mget *.txt

Download and Upload Files using FTP

The post How to Download and Upload Files using FTP Command Line appeared first on TecAdmin.

]]>
https://tecadmin.net/download-upload-files-using-ftp-command-line/feed/ 26
How To Setup VsFTPd Server on CentOS/RHEL 6/5 https://tecadmin.net/setup-vsftpd-server-on-centos-redhat/ https://tecadmin.net/setup-vsftpd-server-on-centos-redhat/#comments Sat, 26 Apr 2014 10:57:44 +0000 https://tecadmin.net/?p=4909 VsFTPd stands for Very Secure FTP Daemon. VSFTPD is the most popular ftp server. Also probably the most secure and fastest FTP server for UNIX-like systems. If you are searching an FTP server which can provide you Security, Performance and Stability then your searching is finished here, vsFTPd can be best suitable option for you. [...]

The post How To Setup VsFTPd Server on CentOS/RHEL 6/5 appeared first on TecAdmin.

]]>
VsFTPd stands for Very Secure FTP Daemon. VSFTPD is the most popular ftp server. Also probably the most secure and fastest FTP server for UNIX-like systems. If you are searching an FTP server which can provide you Security, Performance and Stability then your searching is finished here, vsFTPd can be best suitable option for you.

This article will help you to setup vsFTPd server on CentOS/RHEL and Fedora systems

Features of vsFTPd

Despite being small for purposes of speed and security, many more complicated FTP setups are achievable with vsftpd! By no means an exclusive list, vsftpd will handle:

    • Configure Virtual users
    • Virtual IP configurations
    • Standalone or inetd operation
    • Per-user configuration
    • Bandwidth throttling
    • Source-IP based configuration
    • Limit per source ip
    • IPv6 enabled
    • Encryption support through SSL integration

Step 1: Install vsFTPd

VsFTPd is already available under CentOS default repositories, But to install latest stable release, first enable CentAlt repository in system. Now execute following command.

# yum install vsftpd

Step 2: Configure vsFTPd

VsFTPd has a long list of configuration, here we are making few required configuration now. Edit VsFTPd configuration file /etc/vsftpd/vsftpd.conf in your favorite editor (eg: vim or nano) and update following values

1- Allow anonymous FTP? Set this value to NO to disable anonymous login. default value is YES

anonymous_enable=NO

2- Uncomment below line to allow local system users to log in via ftp

local_enable=YES

3- Uncomment below line to enable any form of FTP write command like, creating or uploading files and directory.

write_enable=YES

4- Set this configuration to restrict local users to there home directories.

chroot_local_user=YES

Read this article to read about more configuration about vsftpd setup.

Step 3: Start VsFTPd Service

VsFTPd provides init script to start stop service. To start vsftp service use following command

# service vsftpd start

In order to stop or restart service use following commands

# service vsftpd stop
# service vsftpd restart

To enable service start on system boot running following command

# chkconfig vsftpd on

The post How To Setup VsFTPd Server on CentOS/RHEL 6/5 appeared first on TecAdmin.

]]>
https://tecadmin.net/setup-vsftpd-server-on-centos-redhat/feed/ 1
What is Active FTP and Passive FTP https://tecadmin.net/active-ftp-vs-passive-ftp-a-definitive-explanation/ https://tecadmin.net/active-ftp-vs-passive-ftp-a-definitive-explanation/#comments Mon, 10 Feb 2014 10:45:52 +0000 https://tecadmin.net/?p=458 FTP (File Transfer Protocol) is TCP based service. FTP is widely used for transferring files over a network. There are various FTP servers are available to use like vsftpd, proftpd, pureftpd etc. FTP uses two different ports – 1. Port 20 is used for the data port, But the data port is not always on [...]

The post What is Active FTP and Passive FTP appeared first on TecAdmin.

]]>
FTP (File Transfer Protocol) is TCP based service. FTP is widely used for transferring files over a network. There are various FTP servers are available to use like vsftpd, proftpd, pureftpd etc.

FTP uses two different ports –

1. Port 20 is used for the data port, But the data port is not always on the 20 port. It may change in passive mode.
2. Port 21 is used as command port.

FTP works in two different modes Active FTP and Passive FTP as per server and client configuration. In this article, I am trying to define Active FTP vs Passive FTP in a definitive explanation, I hope this will help you to understand its working.

Active FTP

In Active mode FTP, the client connects from any random unprivileged port ( For example ‘X’ ( greater than 1023 ) ) to FTP Server port 21. The client again sends the ‘X+1’ port to the FTP server which is acknowledged on the command channel. After that FTP server opens the data channel on port 20 to Clients port X+1.

  • FTP client opens up command channel from client on port 1050 (1050 is for example only) to server port 21.
  • FTP client sends PORT 1051 (1050 + 1) to FTP server and server acknowledges on command channel.
  • FTP Server opens up data channel from server port 20 to client port 1051.
  • FTP client acknowledges on data channel.

Passive FTP

In Passive mode FTP, the client connects from any random unprivileged port (For example ‘X’ (greater than 1023)) to FTP Server port 21. After that client sends a PASV signal to the FTP server command channel to inform the server for using passive mode. FTP server sends back on an unprivileged port (For example ‘Y’ (greater than 1023)). Now FTP client opens the data channel on ‘X+1’ to FTP server PORT ‘Y’. Which acknowledges by the FTP server.

  • FTP client opens up command channel from client on port 1050 (1050 is for example only) to server port 21.
  • FTP client sends PASV command to server on command channel.
  • FTP server sends back (on command channel) PORT 1250 (1250 for example only) after starting to listen on that port.
  • FTP client opens up data channel from client 1051 to server port 1250.
  • FTP server acknowledges on data channel.

I hope the above details may help you understand the difference between Active FTP vs Passive FTP, We are waiting for your comments for whether this article is helpful or not helpful for you. Read our next article, how to download and upload files with ftp.

The post What is Active FTP and Passive FTP appeared first on TecAdmin.

]]>
https://tecadmin.net/active-ftp-vs-passive-ftp-a-definitive-explanation/feed/ 3