How to remove the password prompt when using the remote Copy command scp in linux

Source: Internet
Author: User
How to remove the password prompt when using the remote Copy command scp in linux-Linux Enterprise Application-Linux server application information. The following is a detailed description. Author: Novels

After searching for the Internet for half a day, it is not simple and clear. I will summarize the following:

Write the ssh public key file of your local host user to the remote host user ~ /. Ssh/authorized_keys file, the specific method

Assume that the local host and remote host

1. users in the localhost host

Run ssh-keygen-t rsa

The result is as follows:

Generating public/private rsa key pair.

Enter file in which to save the key (/home/. username/ssh/id_rsa): # Press Enter

Enter passphrase (empty for no passphrase): # Press Enter

Enter same passphrase again: # Press Enter

Your identification has been saved in/home/. username/. ssh/id_rsa.

Your public key has been saved in/home/. username/. ssh/id_rsa.pub.

The key fingerprint is:

38: 25: c1: 4d: 5d: d3: 89: bb: 46: 67: bf: 52: af: c3: 17: 0c username @ localhost

Generating RSA keys:

Key generation complete.

Will be in the user directory ~ /. Ssh/generate two files: id_rsa, id_rsa.pub

The procedure is as follows:

Ssh-keygen-t rsa or ssh-keygen-d (dsa) => Generate id_rsa, id_rsa.pub
Scp id_rsa.pub server_hostname :~ /. Ssh/
Ssh server_hostname
Cat. ssh/id_rsa.pub>. ssh/authorized_keys (append)

In this way, you can log on with key authentication without entering a password.

2. Copy the id_rsa.pub file to the remote host's user directory.

Cat id_rsa.pub >> ~ /. Ssh/authorized_keys

You can.

In this way, users of the localhost can log on to the remote host through ssh without a password.

The following errors are often found during testing:

@ WARNING: remote host identification has changed! @

It is possible that someone is doing something nasty!
Someone cocould be eavesdropping on you right now (man-in-the-middle attack )!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
1f: a3: 2b: b5: 27: 0c: 5c: 7b: 89: 27: ff: AB: cd: ba: 31: 66.
Please contact your system administrator.
Add correct host key in/root/. ssh/known_hosts to get rid of this message.
Offending key in/root/. ssh/known_hosts: 6
RSA host key for 60.28.15.234 has changed and you have requested strict checking.
Host key verification failed.

The solution is to delete the known_hosts file.

3. Enter passphrase (empty for no passphrase ):

Enter is skipped. password will not be asked next time.

Briefly describe:

Id_rsa: private key
Id_rsa.pub: public key

Copy the public key (id_rsa.pub) to the remote computer and add it to. ssh/authorized_keys of the user.

After the connection is established, the private key (id_rsa) of the local machine and the public key (authorized_keys) of the remote computer are used for authentication. After confirmation, you can log on directly without entering the account password, it is also safe.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.