When using SSH and SCP, no password is entered. Objective: to use SSH and SCP on machine A: 192.168.1.2 to operate on machine B: 192.168.1.11, no password is entered. 2. Use SSH-keygen to generate the public key and private key of the current user. The content of the public key is appended to the ~ in the home directory of the corresponding user of the target host ~ /. SSH/authorized_keys; in this way, you can use the private key without entering the password SSH or SCP target host. 3 details: 3.1 ssh-keygen common option-F specifies the key file name-N provides a key pair password-T specifies the type of the key to be created. You can use: "rsa1" (SSH-1) "RSA" (SSH-2) "DSA" (SSH-2) 3.2 instance 1 no key pair password use no key pair password generated key pair, you do not need to enter a password. When using a key pair generated by a key pair, you need to enter the key pair password (the-n parameter value of SSH-keygen or enter passphrase (empty for no passphrase): input) the red font is on 192.168.1.2, and the purple font is on 192.168.1.11 [root @ Test2 ~] # Ssh-keygen-F/root/. Ssh/op_center_rsa-T RSA
Generating public/private RSA key pair. Enter passphrase (empty for no passphrase ):
# Press enter directly and enter same passphrase again without a key pair:
# Press enter directly, without the key pair password your identification has been saved in/root /. SSH/op_center_rsa.your public key has been saved in/root /. SSH/op_center_rsa.pub.the key fingerprint is: F5: 16: 65: D0: 7e: 08: da: DF: 89: 4C: 86: 4C: C9: 6d: 2E: a3 root @ Test2 [root @ Test2 ~] # SCP-p20009/root /. SSH/op_center_rsa.pub 192.168.1.11:/root /. SSH/address 192.168.1.11 maps to Test2, but this does not map back to the address-possible break-in attempt! Root@192.168.1.11's password: op_center_rsa.pub 100% 396 0.4kb/s
[Root @ test11 ~] # Cd. Ssh/
[Root @ test11. SSH] # lsknown_hosts op_center_rsa.pub [root @ test11. SSH] # mv op_center_rsa.pub [root @ test11. SSH] # Cat op_center_rsa.pub> authorized_keys; chmod 0600 authorized_keys; RM-F op_center_rsa.pub # The authorized_keys permission must be 0600 [root @ test11. SSH] # ls-l authorized_keys-rw ------- 1 Root 396 Feb 6 authorized_keys [root @ test11. SSH] # ifconfig | grep "192.168.1.11" Inet ADDR: 192.168.1. 11 bcast: 192.168.1.255 mask: 255.255.255.0 [root @ test11. Ssh] # [root @ Test2 ~] # Ssh-p20009-I/root/. Ssh/op_center_rsa 192.168.1.11 ifconfig | grep "192.168.1.11" # verify whether the key pair takes effect
Address 192.168.1.11 maps to Test2, but this does not map back to the address-possible break-in attempt! Inet ADDR: 192.168.1.11 bcast: 192.168.1.255 mask: 255.255.255.0
[Root @ Test2 ~] #3.3 instance 2 the red font with the key and password is on 192.168.1.2, and the purple font is on 192.168.1.11 [root @ Test2 ~] # Ssh-keygen-F/root/. Ssh/pass_op_center_rsa-t rsa-n "123456"
Generating public/private RSA key pair. your identification has been saved in/root /. SSH/pass_op_center_rsa.your public key has been saved in/root /. SSH/pass_op_center_rsa.pub.the key fingerprint is: A5: B7: 7e: A2: 30: 70: F0: 25: F6: FD: 6B: F1: C0: A7: F3: 9A root @ Test2 [root @ Test2 ~] # SCP-p20009/root /. SSH/pass_op_center_rsa.pub 192.168.1.11:/root /. SSH/address 192.168.1.11 maps to Test2, but this does not map back to the address-possible break-in attempt! Root@192.168.1.11's password: pass_op_center_rsa.pub 100% 396 0.4kb/s [root @ test11 ~] # Cd/root /. SSH/[root @ test11. SSH] # lsauthorized_keys known_hosts pass_op_center_rsa.pub [root @ test11. SSH] # Cat pass_op_center_rsa.pub> authorized_keys; chmod 0600 authorized_keys; RM-F pass_op_center_rsa.pub # The authorized_keys permission must be
0600 [root @ test11. Ssh] # ifconfig | grep "192.168.1.11" Inet ADDR: 192.168.1.11 bcast: 192.168.1.255 mask: 255.255.255.0 [root @ test11. Ssh] # [root @ Test2 ~] # Ssh-p20009-I/root /. SSH/pass_op_center_rsa 192.168.1.11 ifconfig | grep "192.168.1.11" # verify if the key pair takes effect address 192.168.1.11 maps to Test2, but this does not map back to the address-possible break-in attempt! Enter passphrase for key'/root/. Ssh/pass_op_center_rsa ': # enter the content of the SSH-keygen-N parameter Inet ADDR: 192.168.1.11 bcast: 192.168.1.255 mask: 255.255.255.0
[Root @ Test2 ~] # The private key file can also be downloaded to Windows and used for xshell login.
------------- End -------------
From: GS
-------------------------------