[email protected]Support 24/7 · Billing 09:00 – 00:00LinkedInXFacebook
NexonHost
Netherlands Dedicated ServersAmsterdam · Equinix AM6Germany Dedicated ServersFrankfurt · Equinix FR4Romania Dedicated ServersBucharest · VoxilityAustria Dedicated ServersVienna · Interxion VIEBulgaria Dedicated ServersSofia · TelepointFrance Dedicated ServersParis · Interxion PAR — Marseille · Digital Realty MRS3Ireland Dedicated ServersDublin · Equinix DB2Italy Dedicated ServersMilan · Irideos AvalonPoland Dedicated ServersWarsawSpain Dedicated ServersMadrid · Equinix MD2United States Dedicated ServersAshburn · Equinix DC
All articles
Getting startedSeptember 6, 2023

How to Set Up SSH Keys on Debian 10

How To Set Up SSH Keys On Debian 10

This article describes how to generate SSH keys on Debian 10 systems. We will also show you how to set up an SSH key-based authentication and connect to remote Linux servers without entering a password.

 

Creating SSH keys on Debian

The chances are that you already have an SSH key pair on your Debian client machine. If you are generating a new key pair, the old one will be overwritten.

Run the following ls command to check whether the key files exist:

ls -l ~/.ssh/id_*.pub

If the output of the command above contains something like No such file or directory or no matches found, it means that you don’t have SSH keys, and you can continue with the next step and generate a new SSH key pair.

Otherwise, if you have an SSH key pair, you can either use those or backup up the old keys and generate new ones.

Generate a new 4096 bits SSH key pair with your email address as a comment by entering the following command:

ssh-keygen -t rsa -b 4096 -C "[email protected]"

The output will look something like this:

Enter file in which to save the key (/home/yourusername/.ssh/id_rsa):

Press Enter to accept the default file location and file name.

Next, you’ll be prompted to type a secure passphrase. Whether you want to use a passphrase, it’s up to you. The passphrase adds an extra layer of security.

Enter passphrase (empty for no passphrase):

If you don’t want to use a passphrase, just press Enter.

To confirm the SSH key pair was generated, run the following command:

ls ~/.ssh/id_*

The command will list the key files:

/home/yourusername/.ssh/id_rsa /home/yourusername/.ssh/id_rsa.pub

Now that you have your SSH key pair, the next step is to the public key to the server you want to manage.

The easiest and the recommended way to the public key to the remote server is to use the ssh–id tool.

Run the following command on your local machine:

ssh--id remote_username@server_ip_address

You will be prompted to enter the remote_username password:

remote_username@server_ip_address's password:

Once the user is authenticated, the content of the public key file (~/.ssh/id_rsa.pub) will be appended to the remote user ~/.ssh/authorized_keys file, and connection will be closed.
If the ssh–id utility is not available on your local machine, use the following command to the public key:

cat ~/.ssh/id_rsa.pub | ssh remote_username@server_ip_address "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"

 

Login to the Server using SSH Keys

At this point, you should be able to log in to the remote server without being prompted for a password.

To test it, try to connect to the server via SSH:

ssh remote_username@server_ip_address

If you haven’t set a passphrase, you will be logged in immediately. Otherwise, you will be prompted to enter the passphrase.

 

Disabling SSH Password Authentication

To add an extra layer of security to your server, you can disable the SSH password authentication.

Before disabling the password authentication, make sure you can log in to your server without a password, and the user you are logging in with has sudo privileges .

Log into your remote server:

ssh sudo_user@server_ip_address

Open the SSH server configuration file /etc/ssh/sshd_config:

sudo nano /etc/ssh/sshd_config

Search for the following directives and modify as it follows:

PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM no

Once done, save the file and restart the SSH service:

sudo systemctl restart ssh

At this point, the password-based authentication is disabled.

 

Conclusion

We’ve shown you how to generate a new SSH key pair and set up an SSH key-based authentication. You can use the same key to manage multiple remote servers. You have also learned how to disable SSH password authentication and add an extra layer of security to your server.

Keep reading
How to understand what is a DNS server
August 1, 2023

How to understand what is a DNS server

What is a DNS server? The Domain Name System (DNS) is the phonebook of the Internet. When users type domain names such as ‘Google ’ or ‘The New York Times – Breaking News, US News, World News and Videos ’ into web browsers, DNS is responsible for finding the correct IP address for those sites.…

Read article
How to configure hostname and password on the Switch.
July 31, 2023

How to configure hostname and password on the Switch.

What is a switch? The switch is a network device that is used to segment the networks into different subnetworks called subnets or LAN segments. It is responsible for filtering and forwarding the packets between LAN segments based on the MAC address. The switch is a network device that is used to…

Read article
How to understand difference between VPN and Proxy Server.
July 27, 2023

How to understand difference between VPN and Proxy Server.

How To Understand Difference Between VPN And Proxy Server. A proxy server acts as a gateway between you and the internet. It’s an intermediary server separating end users from the websites they browse. Proxy servers provide varying levels of functionality, security, and privacy depending on your…

Read article
Get in Touch

Together, Let’s Build a Faster, Safer Internet.

Build scalable infrastructure with NexonHost — high-performance dedicated servers, VPS hosting, cloud hosting, and DDoS protection across Europe.

Get Started →Contact Us
[email protected]Support 24/7 · Billing 09:00 – 00:00