How to configure SSH on Ubuntu?

To configure SSH login on Ubuntu16.04, follow these steps:

Install OpenSSH: OpenSSH is a free implementation of the SSH as well as SFTP protocols. To install it, type the following command in the terminal:

1
sudo apt-get install openssh-server
1
sudo vi /etc/ssh/sshd_config

Configure SSH Options: You can configure SSH options using an editor (such as nano or vim) to update the following file: /etc/ssh/sshd_config. Here are some important options to consider:

Port: Change the default SSH port (22) to a non-default, secure port using the Port option.
PermitRootLogin: Disable remote SSH root login by changing it to no.
PasswordAuthentication: Disable password authentication and only allow public-key authentication by changing it to no.
Restart OpenSSH service: After modifying the /etc/ssh/sshd_config file, apply your changes by restarting the OpenSSH service:

1
sudo systemctl restart sshd

Add SSH keys: After configuring SSH options, you may want to add public SSH keys to allow secure access from remote computers to your Ubuntu16.04 server.

On the remote computer, create an SSH key:

1
ssh-keygen -t rsa

Copy the public key to your Ubuntu server:

1
ssh-copy-id username@192.168.1.10

Test the SSH connection:

1
ssh username@192.168.1.10

Note: Replace username with the appropriate user on your Ubuntu system, and target_server_ip with the appropriate IP address.

Now, you should be able to log in to your Ubuntu16.04 server via SSH from a remote computer using the private SSH key associated with the public key added earlier.rlier.