# 19.2 FTP The File Transfer Protocol (FTP) is a standard communication protocol used for the transfer of computer files from a server to a client on a computer network. FTP is built on a client–server model architecture using separate control and data connections between the client and the server. FTP users may authenticate themselves with a clear-text sign-in protocol, normally in the form of a username and password, but can connect anonymously if the server is configured to allow it. For secure transmission that protects the username and password, and encrypts the content, FTP is often secured with SSL/TLS (FTPS) or replaced with SSH File Transfer Protocol (SFTP). ### FTP install To use FTP we need to install the commands. ```bash dnf install ftp -y ``` Now that it is installed we can use it to connect to the ftp server. ### FTP useage To connect we use the following command: ```bash ftp -nv server ``` ```bash -n = do not attempt to autoconnect with user -v = verbose messaging ``` ```bash [root@rhcsa ~]# ftp -nv server Connected to server (10.0.1.5). 220 (vsFTPd 3.0.3) ``` We are connected! Now we need to login: ```bash user ftp-user ``` Then give the password **greater** ```bash [root@rhcsa ~]# ftp -nv server Connected to server (10.0.1.5). 220 (vsFTPd 3.0.3) ftp> ls 530 Please login with USER and PASS. Passive mode refused. ftp> user ftp-user 331 Please specify the password. Password: 230 Login successful. ``` Now we can discover what is in the ftp server like a bash command line. ```bash ls ``` ```bash ftp> ls 227 Entering Passive Mode (10,0,1,5,11,200). 150 Here comes the directory listing. -rw-r--r-- 1 0 0 1410 Sep 28 14:50 hello drwxr-xr-x 2 0 0 4096 Feb 11 2022 pub 226 Directory send OK. ftp> ``` ### FTP download Let's download the hello file to our VM: ```bash mget hello ``` Should get the result like this: ```bash ftp> mget hello mget hello? y 227 Entering Passive Mode (10,0,1,5,11,227). 150 Opening BINARY mode data connection for hello (1410 bytes). WARNING! 30 bare linefeeds received in ASCII mode File may not have transferred correctly. 226 Transfer complete. 1410 bytes received in 0.00204 secs (691.85 Kbytes/sec) ftp> ``` We now have the file and we can exit: ```bash exit ``` Check if the file is now on your machine!