Ubuntu 18.04 Ssh Server Install



If not already installed, you can install openssh-server package in Ubuntu 18.04, using the apt-get install command. To install OpenSSH, open the Ubuntu terminal and execute: sudo apt-get update sudo apt-get install openssh-server This will install the SSH Server on our Ubuntu System. Install openssh (sshd) server in Ubuntu 18.04 LTS Yes, new major system upgrade new rules. If you’ve installed openssh server till Ubuntu 18 (Bionic Beaver) with just the simple command. Complete Linux newb trying to get Ubuntu going so that I can learn. I'm getting the following errors when I try to install the SMB client and Open SSh server on a fresh install of 18.04.2.

Install OpenSSH on Ubuntu 18.04

05 Jan 2020 - by 'Maurits van der Schee'

In a previous post I have installed Ubuntu 18.04 on my Dell R720xd. In this post I will show how to install OpenSSH on it, so that we no longer need the iDRAC for system administration. After setting up SSH to securely manage the server we only need the iDRAC when we misconfigure the firewall or the network.

Install OpenSSH

Installing OpenSSH can be done by selecting the 'OpenSSH server' in the software selection screen of the network installer. Alternatively you can install it, or ensure that it is installed, by running the following command:

This should start and enable the SSH server. To verify that it is running you can run:

It should output:

It should output:

Now you can also test connectivity by running:

It should (immediately) output:

You can end the command with Ctrl-C (or pressing enter twice, triggering a 'Protocol mismatch'). If your SSH is not running then there will be no output.

Enable the firewall

To enable UFW (Uncomplicated FireWall) and allow only port 22 (for SSH) towards this server you can run:

To verify that UFW is running, you can run the following command:

It should output:

Showing that only port 22 is allowed on both IPv4 and IPv6.

Avoid double logging

Unfortunately UFW spams the /var/log/syslog by default with 'block' messaging, while it already logs to /var/log/ufw.log. We can avoid this double logging by running:

and changing the last line from:

to:

To make this effective we need to restart the rsyslog service using:

Now your UFW log messages should no longer show up in /var/log/syslog.

Some SSH configuration

You may want to login to the server using SSH on the machine and transfer your public keys.You need to put your public keys (one per line) in the file ~/.ssh/authorized_keys.

Ubuntu 16.04 Server

IMPORTANT: check that you connect to the server without entering a password, before continuing.

Now you can disable (interactive) password logins in the SSH config by running:

change the line:

into:

Now restart ssh for these changes to take effect:

And now the server is online and secure.

Resetting the firewall

If you have made a mess of the firewall rules, then you can run the following to delete all rules (!) and reset everything:

This does not only reset the ufw firewall, but also the (filter chain of the) underlying iptables firewall. By immediately allowing port 22 and 'forcing' the two commands that require confirmation you may even run this over a SSH connection.

SSH usage guidelines

Here are a few rules on good SSH usage for users:

  • NEVER store your SSH (private) key unencrypted (use ssh-keygen -p to set a passphrase).
  • NEVER move (private) keys to another computer, they identify a user at a computer.
  • when using a bastion or jump host, use the ssh -A option (do NOT copy private keys).

Please also consider to use SSH certificates in your cloud infrastructure.

Next: install KVM

In the next post I will walk you through a setup of KVM on Ubuntu 18.04 LTS. We will turn this machine into a proper hypervisor for your virtual machines. I will do this using open source only and also only from the command line.

Click here to read the next article (on installing KVM).

PS: Liked this article? Please share it on Facebook,Twitteror LinkedIn.

Step 0. Install SSH

Open a terminal and type these:

To change config, open the config file:

Change underlined code to this:

Setup Ubuntu Server 16.04

The port number of this ssh server is 22 as written in 5th line.

Step 1. Access to SSH server

Reinstall ubuntu from terminal

To find ipv4 address, install net-tools:

To see the address, type this:

It will show you like this:

That underlined is your (internal) ip address.

To start your ssh server, type this:

Now the server is accessible.

To access the server, from any device that share same network(in my case I’m trying to access from my iPhone), Type this in terminal on your device:

  • You can omit the attribute ‘-p 22’ in case your port number is 22(This is Default). If you use any other port number(you can change it in config file), for example 8282, you need to type ‘-p 8282’ instead.
  • The server will ask you to type password. If your device have SSH Keys such as RSA, ED25519 etc, by exporting the key to the server, you won’t be asked to type password again.
  • In my case, because the server is installed in ubuntu, ubuntu user id and password works for user_name and the passwordbeing asked to type. It is very likely to have some ways to add user-password(RSA etc) pairs to the server manually.

For example, I use Termius app to access the server from my IPhone.

And here goes the magic!:

You can stop the server by typing this:

Or to see the status of the server, type this

  • If your device and your server are not on the same network, you probably will fail to access the server. (for example, try accessing your server from your phone that is being connected to cellular network.) In this case, you need replace the internal IP address to external IP address in the command ‘ssh (user_name)@(ip_address)’. See this post.
  • In my case, the server is built on a VM Box. If you’re doing the same thing I did, you would need to change VM’s network setting. See this post.




Comments are closed.