In this tutorial we will show you how to copy files using SSH. You can transfer files using ssh as per your own requirement and need.
Secure Shell, or SSH, allows you to securely create a remote session which can then be used for ssh file transfer.
Step 1 – List the contents
To see its implementation, let’s list the contents of the directory first.
Step 2 – Create an SSH session with root user
Now we will create an SSH session with the root user, who in this case is the user of the remote system. And after that, we will define the IP address we want to connect with.
With that done, you will be required to type in the root password of the remote system you are connecting with.
Step 3 – List contents of remote system’s home directory
Now you can see that we are in the root folder of the remote system.
Now let’s use the LS command to list the contents of the remote system’s home directory. From here we will copy the veriable.sh script to our local system.
Step 4 – Use the “scp” command
For that, first let’s log out of the remote session and use the “scp” command followed by the user of the remote system. After that, we will type in the IP address followed by the exact path of the file we want to copy.
Step 5 – Enter the password
Now you will be required to type the password of the remote system and hit enter.
With that done, the file will be sent to your system using the ssh file transfer.
Step 6 – List the directory contents
If we list the contents of the directory over here, you can see that the file is now present on our system’s root folder.
And that’s it, from the above steps you can learn how to transfer files using ssh.