FTP/SFTP, SCP or SSH?

FTP/SFTP, SCP or SSH?

A very simple guide to connecting remote servers

·

2 min read

Have you ever wondered how to connect to a remote host? This article is going to introduce some of the commands that you may need when connecting a remote machine! FTP, SCP and SSH are network protocols for different purposes.

FTP/SFTP

File Transfer Protocol (FTP) is a protocol that you can use to transfer files between server and client. SSH File Transfer Protocol (SFTP) is a newer protocol that does the same thing except using a more secure connection, so it is better to use SFTP than FTP whenever possible.

To connect a remote server in SFTP:

sftp username@server

After entering the password, you will be connected to the remote server. You can then use commands like GET or PUT to transfer files from or to the server. For more details, you can type help to view the manual.

SCP

Secure copy protocol (SCP) allows you to copy files between server and client or even between two servers.

To copy a file from client to server:

scp hello.txt username@server:/home

To copy a file from server to client:

scp username@server:hello.txt /home

To copy a file from a server to another:

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

It is not so hard to remember how this command works, because it works just like the cp command:

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) allows you to connect to a remote server and execute almost any commands, not just transferring files. To access the remote server:

ssh username@server

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

Conclusion

The above 3 protocols are just some of the most commonly-used protocols for accessing a remote server. Indeed, there are lots of other network commands or protocols in use. If you are interested in knowing how network works, you should definitely check them out, like rsync and SMB. Another tool that you may find handy when it comes to file transfer is cURL, which is a command line tool for sending or receiving files, and it supports numerous protocols.