• About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap
Linux Tutorials for Beginners
Advertisement
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
No Result
View All Result

Home » Linux » How To Configure SSH Key-based Authentication In Linux

How To Configure SSH Key-based Authentication In Linux

sammbysamm
November 10, 2023
SSH Key-based Authentication

How To Configure SSH Key-based Authentication In Linux

Share on FacebookShare on LinkedinShare on Whatsapp

In the ever-evolving world of cybersecurity, safeguarding your Linux server is of paramount importance. One crucial aspect of securing your server is configuring SSH key-based authentication. In this step-by-step guide, we will walk you through the process of setting up/ Configure Secure SSH key-based authentication in Linux, ensuring a higher level of security while making the login process more straightforward.

Table of Contents

  • What Is SSH Key-Based Authentication?
  • Why Use SSH Key-Based Authentication?
  • Configure SSH Key-based Authentication In Linux
    • Step 1: Generate an SSH Key Pair
    • Step 2: Copy the Public Key to the Server
    • Step 3: Disable Password Authentication
    • Step 4: Test Your SSH Key-Based Authentication
  • Additional Security Tips
  • Conclusion

What Is SSH Key-Based Authentication?

SSH, which stands for Secure Shell, is a widely used protocol for securely connecting to remote servers and managing them. SSH key-based authentication is a method of proving your identity to the server without using a password. Instead, it relies on cryptographic keys, making it a much more secure and convenient way to access your server.

OTHER POSTS

A Simple Guide: How To Manage Groups on Linux

How To Manage Log Files Using Logrotate In Linux

The Easy Ways to Check File Size in Linux

Why Use SSH Key-Based Authentication?

Using SSH key-based authentication offers several benefits:

  • Enhanced Security: Passwords can be guessed or cracked, but SSH keys provide a higher level of security as they are nearly impossible to brute force.
  • No More Passwords: You can log in without entering your password each time, saving you time and effort.
  • Automation: SSH keys are a preferred method for automated processes and scripts, allowing secure, passwordless interactions with the server.

Now, let’s get started with the configuration process.

Configure SSH Key-based Authentication In Linux

In this guide, we will walk through the process of configuring SSH key-based authentication in Linux using Ubuntu Linux and Rockylinux systems as an example.

  • The local system, running Ubuntu 22.04 Desktop, has the IP address 172.32.1.224/24
  • While the remote system, acting as an SSH server, runs Rockylinux 9.2 Server with the IP address 172.32.1.223/24.

Step 1: Generate an SSH Key Pair

The first step is to generate an SSH key pair. To do this, open your terminal and enter the following command:

$ ssh-keygen -t rsa -b 4096 -C "samm@ubuntu"

This command will generate a pair of keys: a private key (usually stored on your local machine) and a public key (to be placed on the server).

Generate SSH
Generate SSH

To update your SSH key with a passphrase, follow these steps if you already have an SSH key without a passphrase in the private file ~/.ssh/id_rsa Open your terminal and use the following command:

$ ssh-keygen -p -f ~/.ssh/id_rsa

Step 2: Copy the Public Key to the Server

Now that you have your SSH key pair, you need to copy the public key to your server. Use the following command to do so, replacing [username] and [server_ip] with your server’s username and IP address:

ssh-copy-id [username]@[server_ip]

You’ll be prompted to enter your server password. Once you’ve done this, your public key will be added to the ~/.ssh/authorized_keys file on the server.

Copy SSH Public Key to SSH Server
Copy SSH Public Key to SSH Server

If you have previously copied the key but wish to update it with a new passphrase, utilize the -f option to overwrite the existing key, as demonstrated below:

$ ssh-copy-id -f [email protected]

Step 3: Disable Password Authentication

To ensure that only SSH key-based authentication is allowed, you should disable password authentication. Open your SSH configuration file using a text editor like nano or vim:

sudo nano /etc/ssh/sshd_config

Look for the line that says PasswordAuthentication and change its value to no:

PasswordAuthentication no

Save and exit the file. Then, restart the SSH service to apply the changes:

sudo systemctl restart sshd

Step 4: Test Your SSH Key-Based Authentication

Before you log out of your current SSH session, it’s essential to test the new configuration to ensure it works correctly. Open a new terminal window and try to SSH into your server:

ssh [username]@[server_ip]

If everything is configured correctly, you should be logged in without entering a password.

Login To Server Using SSH
Login To Server Using SSH

Additional Security Tips

While SSH key-based authentication significantly enhances the security of your Linux server, here are some additional tips to consider:

  • Use Strong Passphrases: If you choose to add a passphrase when generating your SSH key pair, make sure it’s strong and unique.
  • Regularly Update Your Keys: Rotate your SSH keys periodically to maintain security.
  • Limit SSH Access: Restrict SSH access to only trusted IP addresses or networks using the sshd_config file.
  • Monitor Your Server: Keep an eye on server logs for any unusual activities.

Conclusion

In conclusion, configuring SSH key-based authentication in Linux is an essential step in securing your server and ensuring seamless, authorized access. By following this step-by-step guide, you can enhance your server’s security posture while simplifying access management.

By understanding the fundamentals of SSH key-based authentication, generating your key pair, and following best practices, you’ll fortify your Linux server against unauthorized access attempts effectively.

Remember, digital security is an ongoing process. Stay vigilant, keep your systems up to date, and always be proactive in adopting the latest security measures to protect your valuable data and assets.

Also Read Our Other Guides :

  • Initial Setup Debian 11 Server: Secure and Efficient
  • Initial Setup CentOS 7 Server: Secure and Efficient
  • Initial Setup Rocky Linux 9 Server: Secure and Efficient
  • How To Set Up a Firewall with UFW on Ubuntu 22.04
  • How To Set Up a Firewall with UFW on Debian 11
  • How To Manage Log Files Using Logrotate In Linux

Finally, now you have learned how to configure ans secure SSH Key-based Authentication In Linux

Tags: LinuxSecuritySSH

If you got help by our tutorials, please buy me a coffee..!

Buy Me a Coffee

Thank you so much for your support!!

Previous Post

How To Secure SSH with Fail2Ban on Rocky Linux 9

Next Post

How To Backup Files From Remote Linux VPS Using Rsync Script

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

RECENT POST

Install and Secure phpMyAdmin on Ubuntu 22.04

How To Install and Secure phpMyAdmin on Ubuntu 22.04

by samm
July 22, 2024
0

Are you ready to take control of your MySQL databases on Ubuntu 22.04? In this step-by-step guide, we'll walk you...

Manage Groups on Linux

A Simple Guide: How To Manage Groups on Linux

by samm
November 12, 2023
0

Are you a Linux enthusiast looking to enhance your system administration skills? One fundamental aspect you should master is how...

Install phpMyAdmin on Rocky Linux 9

How To Install phpMyAdmin on Rocky Linux 9

by samm
November 11, 2023
0

If you're navigating the world of Rocky Linux 9 and looking to streamline your MariaDB or MySQL database management, installing...

Logrotate In Linux

How To Manage Log Files Using Logrotate In Linux

by samm
November 10, 2023
0

Log files are an essential part of any Linux system. They provide valuable insights into the system's activities, helping administrators...

Load More

RECOMMENDED.

Install Redis on Debian

How To Install Redis on Debian 11 Server

October 16, 2023
Secure SSH with Fail2Ban

How To Secure SSH with Fail2Ban on Rocky Linux 9

October 29, 2023
sammlinux sammlinux sammlinux

Related Posts

Manage Groups on Linux
Linux

A Simple Guide: How To Manage Groups on Linux

November 12, 2023
Logrotate In Linux
Linux

How To Manage Log Files Using Logrotate In Linux

November 10, 2023
Check File Size in Linux
Linux

The Easy Ways to Check File Size in Linux

November 10, 2023
Linux server security system administrators
Linux

Best Practices Linux Server Security for System Administrator

November 10, 2023
Load More
Next Post
Backup Files From Remote Linux VPS Using Rsync Script

How To Backup Files From Remote Linux VPS Using Rsync Script

  • About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap

© 2023 sammlinux - Learn Today for Lead Tomorrow.

No Result
View All Result
  • Ubuntu
  • Debian
  • Rocky Linux
  • CentOS
  • Linux

© 2023 sammlinux - Learn Today for Lead Tomorrow.