Linux Configuration Realizes Key free Login Process Parsing

  • 2021-08-12 04:13:01
  • OfStack

1. ssh Command

In linux, you can log in to another server through ssh command. Open two linux virtual machines, one Linux01 ip is 192.168. 226.128, and the other linux02 is 192.168. 226.129.

Enter ssh 192.168. 226.129 at linux01 terminal after booting, and then prompt to enter the login password of linux02. After entering, you can log in to linux02 on linux01, and you can perform command operation and ssh command in two ways

The ssh ip address (default is the root user) logs in as the root user

ssh username @ ip address login as the specified user

2. Problems solved by key-free login

Now, if you want to log in to linux02 system on linux01, you need to manually enter the password after ssh ip address before entering linux02 server. However, after configuring key-free login, you can log in by directly entering ssh command, instead of manually entering the password. Key-free login solves the problem that mutual access between clusters is limited by passwords. What is a cluster?

Clustering means that many servers do one thing (servers are connected with each other and can transfer data)

3. Configure key-free login:

As long as it is a server in the cluster, it needs to be configured with key-free, not only one server, but other machines can use it

3.1 Generate private and public keys on server linux01 ssh-keygen -t rsa Then click Enter 4 times, do not enter any password, otherwise the key-free failure, see the following information configuration successful


        +--[ RSA 2048]----+
          |     .o.  |
          |      .E.  |
          |      .. . |
          |     o  .  |
          |    S o .. |
          |     o oooo |
          |    . o.+=. |
          |     .B... |
          |     .+.=+. |
          +-----------------+

3.2 Copy one public key on your own computer and generate one on other servers. ssh-copy-id 192.168.226.128 , ssh-copy-id 192.168.226.129

This process requires manually entering the password once, so that a public key is placed on the linux01 server and the linux02 server, and the key-free login is realized through the public key. The following information is successfully configured:

Now try logging into the machine, with "ssh '192.168. 23.144'", and check in:
.ssh/authorized_keys
to make sure we haven 't added extra keys that you weren' t

3.3 Configure the hostname mapping in hosts of linux01: vim /etc/hosts ,

3.4. Repeat the above steps to configure linux02. If there are multiple servers, copy one copy on every server when copying the public key, and configure the mapping of every host for ip mapping. Finally, test and enter ssh ip address to log in directly without entering password

File Transfer: scp-r File/Folder to Copy Destination ip Address or hostname: Destination Folder Path

To send the apps folder on linux01 to home on linux02: scp -r /home/apps 192.168.226.129:/home/ 或 scp -r /home/apps linux02:/home/

You can transfer files


Related articles: