How To Remotely Copy Files Over SSH Without Entering Your Password?

We can easily copy the files from one Linux machine to another using SSH. Here is an example of it.

Copy Files Over SSH

We can use the secure copy command that is very easy to use. Here is the format of the same command.

scp [options] original_file destination_file

You will need to use the remote username and destination path while copying the file.

[email protected] Address:path/to/file

You can use the server IP Address or the resolvable hostname. Here is the complete command to migrate a file from one linux machine to a remote Linux machine.

scp –P 22 /home/test.txt [email protected] Address:/home/user/test.txt

Here, is the explanation of the above command.

scp : Secure Copy
-P  : port number. Here, we have used the default port 22 for the SSH. If you have configured SSH to another port, you will need to use the same port
vpshost : It is a user of the remote server. 
/home/user/ : Destination where we will move the file on the remote server.

You can easily copy the files to the destination remote server using the above command but you will need to enter the remote server password to complete the copying.

Copy Files Over SSH without Password

  1. Run the below command at source machine. You can refer to generate SSH key for more details.

  2. You can run ls command to .ssh directory to view the generated file. id_rsa is your private key and is your private key. Copy the public file to the remote server using scp command. Before that create a directory called authorizedkey_2 at remote server inside the /.ssh directory.

    scp –P 22 /root/.ssh/ [email protected] Address:/root/.ssh/
  3. Now run the below command at your remote server.

    cat .ssh/ >> .ssh/authorized_keys
  4. Give the below permission to .ssh/authorized_keys folder.

    chmod 600 .ssh/authorized_keys 
  5. Finally try to test copy files without password from source to remote server and you will see it will not ask for the password.

    scp –P 22 /home/test.txt [email protected] Address:/home/test.txt

Related Articles

How to setup Database Map tool from WHM Panel?

cPanel provide a feature called Database Map tool. You can provide ownership of databases and...

Can I open APN port 2195 on my VPS?

You will get full administrative control of your VPS, therefore you can surely open/close any...

How to reset MySQL 8.0 root password on Centos 7.x?

You may need to reset your MySQL root password if you lost or forget it. MySQL stores the...

How to Setup MySQL Master-Slave Replication on RHEL 7?

In MySQL Replication process, one server data is automatically copied to another backup server in...

How to Enable Plaintext Authentication in Dovecot?

Dovecot is an Open source IMAP or POP3 server used to create light-weight and high-performance...

  • 0 Users Found This Useful

Was this answer helpful?