In Linux systems, SSH is the default tool for remote logins because the tool's protocol uses the RSA/DSA encryption algorithm. This tool is very secure for remote management of Linux systems.
SSH logon to the remote host (server) generally there are two ways: no key mode and a key method.
No key method needs to enter the password every time, and the key method only need to enter the password for the first time, no need to enter a password in the future to correctly login.
1 Installing SSH
Server side needs to install and turn on SSH service
Client side needs to support Ssh-keygen command
The which command can be used to verify:
which SSH
Or, use the SSH command directly to view:
Confirm that two machines can connect to the Internet
2 using SSH
2.1 No Key mode
Use format: SSH user name @ host IP
The remote host IP is 192.168.31.116.
2.2 have a key way
① generating key pair (client side)
SSH ' -F ~/.ssh/id_rsa
After executing the above command, the hidden directory is generated in the current directory. SSH. Using the Ls-l (abbreviated LL) command, we found that two new files were generated: Id_rsa is the private key, and Id_rsa.pub is the public key.
It should be noted that the public key is public and does not require secrecy, while the private key is owned by the individual and must be kept and kept in mind.
② Add the client's public key to the server-side public key file for authentication
Ssh-copy-id [Email protected]_address
After executing the above command, you can see the Authorized_keys file generated under the user directory/.ssh directory on the server side.
③ Disable SSH login via password on server side
sudo vim/etc/ssh/sshd_config
After opening the file, uncomment the frame's statement (Allow automatic login with key):
④ Restart the SSH service:
sudo service ssh restart
⑤ SSH login on the client, found that no longer need to enter the password to log in directly.
SSH User name @ host IP
Connect to a remote host using SSH