# FTP vs SFTP vs SCP vs SSH: Which One to Use?

Have you ever wondered how to connect to a remote host? This guide introduces essential commands for connecting to remote machines. We'll explore three key network protocols: FTP, SCP, and SSH.

# FTP/SFTP

File Transfer Protocol (FTP) is used to transfer files between a server and a client. SSH File Transfer Protocol (SFTP) is a newer, more secure version of FTP. For this reason, SFTP is the preferred choice whenever possible.

To connect to a remote server using SFTP:

```bash
sftp username@server
```

Once you've entered your password and connected to the remote server, you can use commands like `GET` or `PUT` to transfer files. Type `help` to view all available commands.

# SCP

Secure Copy Protocol (SCP) lets you copy files between a server and a client, or between two servers.

To copy a file from a client to a server:

```bash
scp hello.txt username@server:/home
```

To copy a file from a server to a client:

```bash
scp username@server:hello.txt /home
```

To copy a file from one server to another:

```bash
scp username@server1:hello.txt username@server2:/home
```

The SCP command is easy to remember because it works similarly to the cp command:

```bash
cp source destination
scp local_file server:directory # copy file from local to server
scp server:file directory # copy file from server to local
```

# SSH

Secure Shell Protocol (SSH) lets you connect to a remote server and run almost any command, not just transfer files. To access the remote server, use the following command:

```bash
ssh username@server
```

After logging in, you can do almost anything to interact with the server.

# Conclusion

The three protocols mentioned above are some of the most commonly used for accessing a remote server. There are many other network commands and protocols in use. If you are interested in learning how networks work, you should definitely explore them, such as `rsync` and SMB. Another useful tool for file transfer is `cURL`, a command line tool for sending or receiving files that supports numerous protocols.
