In this tutorial, I will configure the SSH connection with key authentication.
How it works
- (Client) Generate a set of secret key and public key
- (Connection destination server) Register public key
- (Connection destination server) Accepts a connection from a client, encrypts the random number using the public key
- (Connection destination server) Hashed random number
- (Client) hashes the received random number and forwards the hash value to the server
- (Connection destination server) Compare the hash value sent by the client and the hash value generated on the server side
Set up SSH connection with key authentication.
1: Generation of a key set
ssh-keygen -t rsa -f client01
2: Public Key Registration
# Work on the server, target users to connect cat client01.pub >> .ssh/authorized_keys
3: Enabling Key Authentication
# vim /etc/ssh/sshd_config RSAAuthentication yes PubkeyAuthentication yes AuthorizedKeyFile .ssh/authorized_keys # Disable password authentication if you want to strengthen it PasswordAuthentication no
Try to connect
ssh -i .ssh/client01 -p12345 huupv@devopsroles
Thought the article, How to configure SSH connection with key authentication in Linux. Thank you for reading the DevopsRoles page!