This article is a mirror article of machine translation, please click here to jump to the original article.

View: 9887|Reply: 3

[linux] Linux Secretless Login (ssh) or Secretless Copy (scp) files to other servers

[Copy link]
Posted on 2/17/2022 11:17:27 AM | | | |
Requirements: There are two servers, A (10.7.45.131) and B (10.7.45.132), in order to enable server A to log in passwordlessly when connecting to server B via SSH, or copy server A files to server B through the scp command.

The tutorial is as follows:

1. Log in to server A and run the following command to generate a pair of ssh public and private key files, as follows:



Under the ~/.ssh/ directory, two files will be generated, id_rsa (private key) id_rsa.pub (public key), as shown in the figure below:

2. Use the ssh-copy-id command to copy or upload the public key to the remote host (perform the upload from server A to server B) with the following command:

As shown below:



ssh-copy-id command to copy the local host's public key to the remote host's authorized_keys file,
The ssh-copy-id command also sets the appropriate permissions for the remote host's home directory (home) and ~/.ssh, and ~/.ssh/authorized_keys.
The ssh-copy-id command can install the local ssh public key file to the account corresponding to the remote host.
Log in to server B, look at the /root/.ssh folder, and find that the authorized_keys file is generated, as shown in the figure below:







Previous:[Practice] Java cannot catch custom exceptions using hutool reflection
Next:[Actual combat]. NET/C# uses SemaphoreSlim to limit concurrent execution methods
 Landlord| Posted on 12/10/2022 11:34:01 AM |
CentOS 7 copies files to another server via commands
https://www.itsvse.com/thread-10012-1-1.html
 Landlord| Posted on 6/5/2025 9:48:59 AM |
For non-default port 22:
 Landlord| Posted on 8/4/2025 8:54:21 AM |
Linux uses rsync to synchronize data to the new server
https://www.itsvse.com/thread-11045-1-1.html
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com