Вы находитесь на странице: 1из 3

https://www.rosehosting.

com/blog/how-to-install-and-configure-openssh-on-ubuntu-16-04/

Install OpenSSH on Ubuntu 16.04


First, let’s install OpenSSH. Update the package index using the following command:

sudo apt-get update

To install the OpenSSH server application as well as the other related packages use the command
below:

sudo apt-get install openssh-server

Please note that the OpenSSH server package could be already installed on your system as part
of the initial server installation process. Furthermore, you can install the OpenSSH client
application using the following command:

sudo apt-get install openssh-client

Configure OpenSSH on Ubuntu 16.04


Before making any changes in your OpenSSH configuration, it is good to know how to manage
the OpenSSH service on your Ubuntu VPS. To start the service you can use the following
command:

sudo systemctl start sshd.service

To stop the service you can use:

sudo systemctl stop sshd.service

To restart the service you can use:

sudo systemctl restart sshd.service

To check the status of the service you can use:

sudo systemctl status sshd.service

To enable the service on system boot you can use:

sudo systemctl enable sshd.service

To disable the service on system boot you can use:

sudo systemctl disable sshd.service


After making any changes in the OpenSSH configuration you need to restart the service for the
changes to take effect.

The main configuration file for the OpenSSH server application is /etc/ssh/sshd_config.
Make sure you create a backup of the original configuration before making any changes:

sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.orig

You can edit the file by using a text editor of your choice. The first thing you may want to do is
to change the default SSH listening port. Open the file and locate the line that specifies the
listening port:

Port 22

Change it to something else. For example to 2022

Port 2022

Save the file and close it. Then restart the service for the changes to take effect.

Now you can try to connect to your server via SSH using the port number you specified in the
OpenSSH server configuration file. If you can connect to the server via SSH successfully you
can continue with the next step which is securing OpenSSH.

Secure OpenSSH on Ubuntu 16.04


One of the recommended ways to secure your server when using OpenSSH is to disable the Root
login. First, create a new sudo user on your Ubuntu server, and then edit the OpenSSH server
configuration file. Locate the following line:

#PermitRootLogin yes

and change it to:

PermitRootLogin no

Save the changes and restart the service for the changes to take effect. The next time you connect
to the server you can use the newly created sudo user.

To secure the server furthermore, you can disable password authentication and configure SSH
login using SSH keys. Also, you can secure SSH by using two-factor authentication.

For more configuration options you can check the man page:

man sshd_config

or you can visit the OpenSSH manual pages at https://www.openssh.com/manual.html.


Of course, you don’t have to install and configure OpenSSH on Ubuntu 16.04, if you use one of
our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to
install and configure OpenSSH on Ubuntu 16.04 for you. They are available 24×7 and will take
care of your request immediately.

PS. If you liked this post on how to configure and use OpenSSH on Ubuntu 16.04, please share it
with your friends on the social networks using the buttons on the left or simply leave a reply
below. Thanks.

Вам также может понравиться