SSH has two ways of connecting
The first type: Password Authentication connection mode
[[email Protected] ~]# ssh [email protected] (the IP return prompt for the server is as follows)
The authenticity of the host ' 192.168.1.250 (192.168.1.250) ' can ' t be established.
RSA key fingerprint is 75:f9:55:3b:da:0d:38:b2:c6:1b:e9:18:96:97:8a:2e.
is you sure want to continue connecting ( yes/no)? (enter Yes to guarantee key return)
warning:permanently added ' 192.168.1.250 ' (RSA) to the list of known hosts.
[email protected]' s password: (input password Enter)
The second type: Key connection mode
[[email protected] ~]# Ssh-keygen (startup key connection mode)
Generating public/private RSA key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): ( the place where the key is kept is guaranteed by default
exists in the current user directory as required
Modify, enter hold address)
Enter passphrase (empty for no passphrase):(Use default return if password is used)
Enter same Passphrase again:
Your identification has been saved In/root/.ssh/id_rsa.
Your public key has been saved in/root/.ssh/id_rsa.pub.
The key fingerprint is:
E4:4d:4c:b7:e4:ec:07:d5:a7:f0:3c:a0:b0:1f:98:a1[email protected]
The key ' s Randomart image is:
+--[RSA 2048]----+
| . O.. |
| OO =oo o|
| .. *o.==. |
| Eo+oo. .= |
| S ... |
| . . |
| |
| |
| |
+-----------------+
After the key is generated, enter the. ssh/directory to see
[[Email protected] ~]# CD. ssh/
[email protected]. ssh]# ls
Id_rsa id_rsa.pub known_hosts (id_rsa.pub) This file is the key authentication file
[email protected]. ssh]# ssh-copy-id-i id_rsa.pub [email protected] (sends the key to the server)
[email protected]' s Password: (Enter the service-side password) Enter the prompt as follows to succeed
Now try logging to the machine, with "SSH '[email protected]' ", and check in:
. Ssh/authorized_keys
To make sure we haven ' t added extra keys so you weren ' t expecting.
Note: If the system is installed or if other conditions are not properly connected, remove the files from the. ssh/directory and reconfigure them.
If you want to compare security or control user login into cd/etc/ssh will see
[email protected]. ssh]# cd/etc/ssh
[[email protected] ssh]# ls
Moduli Ssh_host_dsa_key ssh_host_key.pub
Ssh_config ssh_host_dsa_key.pub Ssh_host_rsa_key
Sshd_config Ssh_host_key ssh_host_rsa_key.pub
Ssh_config This is the client configuration file, Sshd_config This is the server configuration file to modify this.
Open Ssh_config with Vim
Syslogfacility Authpriv
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
#PermitRootLogin Yes (change this to No to disable root login)
#StrictModes Yes
#MaxAuthTries 6
#MaxSessions 10
# To disable tunneled clear text passwords, change to No here!
#PasswordAuthentication Yes
#PermitEmptyPasswords No
Passwordauthentication Yes (change this to No to use password Authentication)
How CentOS connects to a host remotely using SSH