Debian Generate Ssh Server Keys

Jan 11, 2007  Secure your SSH server with Public/Private key authentification 2 minute read Open SSH is the most widely used SSH server on Linux. Using SSH, one can connect to a remote host and gain a shell access on it in a secure manner as all traffic is encrypted. A neat feature of open SSH is to authenticate a user using a public/private key pair to log into the remote host. Jul 08, 2019  SSH, or secure shell, is an encrypted protocol used to administer and communicate with servers. When working with a Debian server, chances are you will spend most of your time in a terminal session connected to your server through SSH. In this guide, we’ll focus on setting up SSH keys for a vanilla Debian 10 installation.

In this article, I will show you how to install and configure SSH server on Debian 9 Stretch for remote login. Let’s get started.

Installing SSH Server:

First update the apt package repository cache of your Debian operating system with the following command:

Your apt package repository cache should be updated as you can see in the screenshot below.

On Debian, SSH server comes as ‘openssh-server’ package. To install OpenSSH on Debian, run the following command:

Press ‘y’ and then press <Enter> to continue.

OpenSSH server should be installed.

On Debian, the default behavior of OpenSSH server is that it will start automatically as soon as it is installed. You can also check whether OpenSSH server is running on it with the following command:

You should see ‘active (running)’ status as shown in the screenshot below. Which means SSH server is running. It is also listening on port 22.

If in any case OpenSSH server is not running, you can run the following command to start OpenSSH server.

Remove SSH Server from startup:

By default, on Debian, OpenSSH server should start automatically on system boot. If you don’t want it to start on boot then first stop the OpenSSH server with the following command:

Now if you check the status of your OpenSSH server, you should see that it is not running as shown in the screenshot below.

Keys

Now disable OpenSSH server from startup with the following command:

Generate

Start OpenSSH Server on boot:

If you want to start OpenSSH server on boot again, just run the following command:

Now start OpenSSH server with the following command:

If you check the status of OpenSSH server now, you should see that it is running as shown in the screenshot below.

Connecting to the SSH server remotely:

Before you can connect to the SSH server remotely, you must know the IP address of the SSH server.

To find out what the IP address of the computer running the SSH server, run the following command from that computer:

You can see from the screenshot that the IP address of the computer I have SSH server installed on is 192.168.10.82

Now, to connect to this machine from another computer, run the following command:

Debian Generate Ssh Server Keys Windows 10

I will connect to the SSH server as user ‘shovon’ and with the IP address 192.168.10.82 from my Ubuntu 17.10 machine.

Once you press <Enter>, you should see the following prompt if it is the first time connecting to the SSH server, which it is.

Just type ‘yes’ and press <Enter>.

Then you should be prompted to enter the login password of the user you’re login as. Enter the password and press <Enter>.

You should be connected to the SSH server as that user. The hostname changed from ‘linuxhint-pc’ to ‘linuxhint’ as you can see from the screenshot below.

You can further verify that you’re connected to the remote server with the following command:

Ubuntu 18.04 Generate Ssh Host Keys

You can see that the IP address is 192.168.10.82! The IP of our SSH server!

You can run any command you want here and manage the remote server using SSH. You may even buy a Public IP and control your server from anywhere around the globe.

When you’re done configuring, just run the following command to close the SSH connection.

See? You’re logged out back into the ‘linuxhint-pc’.

Linux Generate Ssh Host Keys

root Access to the Remote Server with SSH:

Now if you want root access to the remote server, you may try to login as root with the following command:

But root access in modern operating system this way is disabled by default. It is also the case for Debian. There’s a ‘configurationless’ workaround, just login as an ordinary user and become root with the following command:

Enter your root password and you should be logged in as root as shown in the screenshot below.

You can change the configuration of your SSH server to allow direct root login as well.

Ubuntu Add Ssh Key

To do that, open the ‘/etc/ssh/sshd_config’ configuration file with ‘nano’ with the following command:

The file should look like this.

Scroll down a little bit. You should see the line as marked in the screenshot below.

Remove the # sign before PermitRootLogin and change ‘prohibit-password’ to ‘yes’. Once you’re done, press Ctrl+X , press ‘y’ and then press <Enter> to save the file.

Now restart the SSH server with the following command:

Now you should be able to connect as ‘root’ user directly as shown in the screenshot below.

Who generates the session key. OpenSSLon Windows is not currently supported.Important:After you install the session key forwarder software on Windows 2012 R2 orWindows 2016 systems, applications that include SSL-enabled features, such as Microsoft Edge andWindows Store applications that incorporate sandboxing features, might fail to functioncorrectly.Validate the compatibility of the session key forwarder in your Windows testenvironment before deploying in your production environment.

That’s how you enable SSH server for remote login on Debian 9. Thanks for reading this article.