Transfer Files Command Line
In this lesson we will use the
Command Line File Transfer Video Tutorial
Here are some commands and software that will faciliate the lesson.
To log into a remote server from our local machine, we will use SSH. If you are using my tutorals, this is a great way to access your virtual server from your local environment. If you use windows you may use puTTY to SSH into a remote server. If you use Linux, just open your terminal application and you are good to go!
To Install OpenSSH on Ubuntu:
~$ sudo apt update
~$ sudo apt install openssh-server
~$ sudo apt install openssh-client
To verify SSH works
~$ sudo systemctl status ssh
If it says the server is "active (running)", you are all set!
Not sure the location of your file or directory? the pwd command with give you the present working directory.
When using SSH or SCP, you must specify your host. You can do this by host name or ip address. The ifconfig command is handy for checking your ip.
Mouse Hover over the ➼ blue text in the descriptions to highlight the command above.
Transfer File From Remote Server to Local Server
~$ scp <remote_user_name>@<remote_host>:</remote_file_location> <destination/>
~$ scp firstname.lastname@example.org:/home/commander/code/hatnix.php test/
➼ scp secure copy command
➼ commander remote user name
➼ 192.168.1.74 remote host (ip address)
➼ File Location of the remote file you wish to copy
➼ test/ The local destination for the file.
Transfer File From Local to Remote Server
~$ scp <file_location> <remote_username>@<remote_host>:<remote_destination>
~$ scp test/nurse.py email@example.com:/home/commander/code
➼ local file - This is the file you want to transfer to the remote server
➼ commander - Remote username
➼ 192.168.1.74 - Remote host (ipaddress)
➼ destination - The directory on the remote server where you want to put your local file.
Transfer Directory From Remote Server to Local Server
To transfer directories, we use
~$ scp -r <remote_user_name>@<remote_host>:<remote_directory_location> <destination/>
~$ scp -r firstname.lastname@example.org:/home/commander/code/ test/
Transfer Directory From Local to Remote Server
~$ scp -r <directory_location> <remote_user_name>@<remote_host>:<remote_destination/>
~$ scp -r test/ email@example.com:/home/commander/code