Configure SSH connection with key authentication

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 >> .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!

, , ,

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published.

Comment moderation is enabled. Your comment may take some time to appear.

This site uses Akismet to reduce spam. Learn how your comment data is processed.