How to transfer files from PC to VPS – Secure and efficient
So you got yourself a new VPS machine and sure, its fast, its awesome, but you are perhaps not as familiar with the terminal as you would like to be and you are not sure how you are supposed to transfer files from PC to VPS. But don’t worry, we will guide you through it.
Unless you have a managed VPS that would often come with some kind of file manager, the easiest way would be to use terminal. It’s possible to install some sort of file manager and set it up, but there is no need to complicate things.
There is a tool called SCP and it comes with almost any Linux distribution, but it can be used on Windows as well. So let’s jump right into it.
What is SCP?
SCP (secure copy) is a command line tool that allows you to securely copy/send any file or files between two servers. It relies on SSH for data transfer, and so you can be sure that the files are tightly secured since everything, including the files, is encrypted during the transfer.
With SCP you can do the following:
- Send files from your local system to remote system
- Send files from the remote system to your local system
- Send files between two remote systems
And all that can be done from either of those machines participating. Meaning, you can both download and upload files by running a simple command in your local terminal.
How to use SCP to transfer files from PC to VPS?
If you are using Windows(Windows 10), please go to this link and make sure SSH Client is enabled/installed on your OS and then come back to follow the next steps.
Step 1 – Make sure SSH connection to your VPS works
For this, we are using one of our own VPS machines with Ubuntu 22.04 installed on them. SSH comes by default, and so does SCP. We just need to make sure that both SSH on your end and end of your VPS works properly.
On your PC open up a terminal and just type the following command:
Replace “root” with username of your VPS(leave it root if its root), and “184.108.40.206” with IP of your VPS.
After entering a password, if a connection was successful, we can proceed. Please feel free to close the connection by typing “exit”.
Step 2 – Find the files that you want to send to your VPS
By using command “cd”, enter the directory of the files that you want to transfer.
In this example, we will be sending file “serverlynx_testfile” to our VPS machine with the IP 220.127.116.11.
The command is the following:
scp serverlynx_testfile [email protected]:/root/
- replace “serverlynx_testfile” with your file name that is in the current directory, or if you prefer, give the full path such as /home/Documents/serverlynx_testfile
- replace “root” with your VPS username
- replace 18.104.22.168 with your VPS IP
- replace “/root/” with the path ON THE VPS machine where you want to send files(if unsure, leave it as it is, all linux VPS servers have /root/ path)
Now just enter the password of your VPS, and the files will be transferred. You should see something like this:
That would mean the transfer was successful and you should be able to find the file on your VPS in the location that you specified in the command.
Step 3 – Explore other SCP capabilities
Congratulations! You have successfully sent files to your VPS and learned something new. We know that at first there is maybe a lot of information, but it’s not hard once you get used to it.
Now, we will list you some other commands that you will be able to use for different scenarios. Feel free to experiment!
If your VPS is using different SSH port(default is 22):
scp -P 1234 example.txt vps_username@vps_ip:/example/example/
When you want to download a file from VPS to your PC:
scp vps_username@vps_ip:/remote/example.txt /local/directory
Want to copy a whole directory from your PC to VPS? Try this:
scp -r /local/directory vps_username@vps_ip:/remote/directory
If you want to send files from one VPS to another directly from your PC(you must have access to both VPS machines):
scp vps_1_username@vps_1_IP:/directory1/file1.txt vps_2_username@vps_2_ip:/directory/
This command will send “file1.txt” to VPS 2. You will get prompted to enter passwords for both of them.
SCP is an awesome tool for quick and secure transfers that utilizes the best standards out there. We personally prefer it over FTP. Once you get used to it, there is no going back, it’s simply magical.
We hope we have managed to help you and that you have learned today how to transfer files from PC to VPS. If you have any suggestions for this article, feel free to reach out to us and we will make sure to make it even better.
Until next time!