Ssh Ubuntu Server 18.04



In Ubuntu 18.04 server, SSH server is an option during the installation process and your Ubuntu system probably has the OpenSSH server installed already. If you are not sure, run the following command to check whether you have SSH server installed already. Dpkg -get-selections grep openssh. How To Install SSH Server Ubuntu 18.04 Bionic Beaver. 2018-10-20 Super Linux Tutorials, Ubuntu 18.04 Basics, Ubuntu 18.04 Tutorials 0. Step 1: Install & Configure SSH Server. 1.1 Install SSH server. Sudo apt-get install openssh-server -y 1.1.a Edit SSH server configuration file. Author neoX Posted on July 12, 2018 Categories Ubuntu Tags linux, openssh, sshd, tasksel, ubuntu 18.04 lts, ubuntu18 Leave a Reply Cancel reply Your email address will not be published. Download openssh-server7.6p1-4amd64.deb for 18.04 LTS from Ubuntu Main repository.

In this tutorial we are going to install OpenSSH on Ubuntu 18.04. OpenSSH is most popular SSH server solution for Ubuntu Linux.

In Ubuntu 18.04 server, SSH server is an option during the installation process and your Ubuntu system probably has the OpenSSH server installed already. If you are not sure, run the following command to check whether you have SSH server installed already.

If you see openssh-server in the output, SSH server is installed already. Otherwise, you can install openssh-server package with following command:

After you’ve installed the openssh-server package, check the status of the ssh service with the systemctl command:

The status should be active (running), if not run following two commands to start and enable the ssh service:

You can also run the ss command to make sure that the Ubuntu system listen on TCP port 22.

If the Ubuntu firewall is enabled, you need to add a firewall rule that allows TCP port 22 inbound.

18.04

Next: Enable SSH Root Login

Connecting to the Ubuntu via ssh command

The ssh command is a command line SSH client available in every Linux/Unix operating system. It is a very simple and easy to use SSH Client for Ubuntu Linux.

To connect to that server via SSH, execute the ssh command followed by the IP address or domain name of the Ubuntu server:

Or

The ssh command by default will try to log in to the remote server with the same username you are using on your local Linux machine. For example, if you have logged in to your local Linux machine as a root user, then the ssh command will try to connect to the remote server as the root user.

If you want to login as a different user, use the -l option:

Alternatively, you can also use the following format (username@ip-address):

On windows you can get SSH command by installing the GIT bash shell or you can use an SSH client like Putty.

Also by default ssh command will connect to the remote server via port 22, which is the default SSH port. If you have changed the port for SSH on your Ubuntu server, then use the -p option to specify the port to connect to on the remote host:

In the preceding example, we connect to the remote server via port 22000.

Establishing an SSH (Secure Shell) connection is essential to log in and effectively manage a remote server. Encrypted keys are a set of access credentials used to establish a secure connection.

This guide will show you how to generate SSH keys on Ubuntu 18.04. We will also cover setting up SSH key-based authentication to connect to a remote server without requiring a password.

  • A server running Ubuntu 18.04, SSH enabled on Ubuntu
  • A user account with sudo privileges
  • Access to a terminal window/command line (Ctrl-Alt-T)

On your client system – the one you’re using to connect to the server – you need to create a pair of key codes.

To generate a pair of SSH key codes, enter the commands:

This will create a hidden directory to store your SSH keys, and modify the permissions for that directory. The ssh-keygen command creates a 2048-bit RSA key pair.

For extra security, use RSA4096:

If you’ve already generated a key pair, this will prompt to overwrite them, and those old keys will not work anymore.

The system will ask you to create a passphrase as an added layer of security. Input a memorable passphrase, and press Enter.

This process creates two keys. One is a public key, which you can hand out to anyone – in this case, you’ll save it to the server. The other one is a private key, which you will need to keep secure. The secure private key ensures that you are the only person who can encrypt the data that is decrypted by the public key.

First, get the IP address of the Ubuntu server you want to connect to.

In a terminal window, enter:

The system’s IP address is listed in the second entry:

On the client system, use the ssh-copy-id command to copy the identity information to the Ubuntu server:

Replace server_IP with the actual IP address of your server.

If this is the first time you’re connecting to the server, you may see a message that the authenticity of the host cannot be established:

Enable Ssh On Ubuntu Server 18.04

Type yes and press Enter.

The system will check your client system for the id_rsa.pub key that was previously generated. Then it will prompt you to enter the password for the server user account. Type it in (the system won’t display the password), and press Enter.

Install Ssh In Ubuntu Server 18.04

The system will copy the contents of the ~/.ssh/id_rsa.pub from the client system into the ~/.ssh/authorized_keys directory of the server system.

The system should display:

If your system does not have the ssh-copy-id command, you can copy the key manually over the SSH.

Ubuntu Hardening Guide

Use the following command:

To log in to a remote server, input the command:

The system should not ask for a password as it is negotiating a secure connection using the SSH keys. If you used a security passphrase, you would be prompted to enter it. After you do so, you are logged in.

If this is the first time you’ve logged into the server, you may see a message similar to the one in part two. It will ask if you are sure you want to connect – type yes and press Enter.

This step creates an added layer of security. If you’re the only person logging into the server, you can disable the password. The server will only accept a login with your private key to match the stored public key.

Edit the sshd_config file:

Search the file and find the PasswordAuthentication option.

Edit the file and change the value to no:

Save the file and exit, then restart the SSH service:

Verify that SSH is still working before ending the session:

If everything works, you can close out and resume work normally.

By following the instructions in this tutorial, you have setup SSH-key-based authentication on an Ubuntu 18.04 server.

Ssh Ubuntu Server 18.04

The connection is now highly secure as it uses a set of unique, encrypted SSH keys.

Next you should also read

This article will help system administrators configure SSH Keys on Debian 10. The instructions allow you to…

Learn how to set up SSH key authentication on CentOS to safely communicate with remote servers. Create the…

When establishing a remote connection between a client and a server, a primary concern is ensuring a secure…

In this tutorial, Find out How To Use SSH to Connect to a Remote Server in Linux or Windows. Get started with…