Here’s How You Can Copy Files over SSH Without Password

Here’s How You Can Copy Files over SSH Without Password

Typically when you use SSH to copy files from one server to another, you’re required to provide the password. The process goes something like this:
  • You use the secure copy command and name the original file and the destination file like this:
scp [options] original_file destination_file
  • You provide the remote username and destination path for copying
username@serverIP Address:path/to/file
  • Here’s the complete command to migrate a file from one Linux server to another:
scp –P 22 /home/test.txt vpshost@serverIP Address:/home/user/test.txt
If you need more information on the above command, here’s a brief explanation:
  • scp stands for secure copy command
  • -P is the port number
  • vphost is the user of the remote server
  • /home/user/test.txt is the destination where you’ll be moving the file to
The above process will require providing the remote server password.

How to Copy Files without a Password?

You can copy files from one Linux server to another by following these steps:
  • Execute this command at source machine (it will generate a file which you can view by running is command to .ssh directory):
  • Then run this command to copy the generated file to the remote server:
scp –P 22 /root/.ssh/ vpshost@serverIP Address:/root/.ssh/
  • Now you must have created a directory called authorizedkey_3 at the remote server and placed it inside the /.ssh directory. Then run this command at the remote server:
cat .ssh/ >> .ssh/authorized_keys
  • Execute this command to give permission to .ssh/authorized_keys folder:
chmod 600 .ssh/authorized_keys
  • Now you can test with copying files to the remote server and it shouldn’t ask for password. Use this command now:
scp –P 22 /home/test.txt vpshost@serverIP Address:/home/test.txt
So that’s how you copy files to a remote Linux server over SSH without the need for a password.
First release
Last update
0.00 star(s) 0 ratings

More resources from kumkumsharma