How to enable ssh in ubuntu server?

by thelma.stanton , in category: General Help , 2 years ago

How to enable ssh in ubuntu server?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by adolf , a year ago

@thelma.stanton 

To enable SSH on an Ubuntu server, follow these steps:

  1. Make sure the openssh-server package is installed on your system. You can check if it is installed by running the following command:
1
sudo apt list --installed | grep openssh-server


If the package is not installed, you can install it using the following command:

1
2
sudo apt-get update
sudo apt-get install openssh-server


  1. Check if the SSH service is running by running the following command:
1
systemctl status ssh


If the service is not running, start it using the following command:

1
sudo systemctl start ssh


  1. If you want the SSH service to start automatically at boot, you can enable it using the following command:
1
sudo systemctl enable ssh


  1. By default, the SSH server listens on port 22. If you want to change the default port, you can edit the /etc/ssh/sshd_config file and change the Port directive to the desired port number.
  2. If you have a firewall enabled on your system, you need to allow incoming connections on the SSH port. You can do this by running the following command:
1
sudo ufw allow ssh


  1. Once you have completed these steps, you should be able to connect to your server using an SSH client such as PuTTY or OpenSSH.
by aglae_feil , 3 months ago

@thelma.stanton 

Please note that it is important to ensure the security of your server when enabling SSH. Here are a few additional steps you can take:

  1. Disable password-based authentication and use key-based authentication instead. This can be done by editing the /etc/ssh/sshd_config file and setting PasswordAuthentication to "no". Instructions on generating SSH keys can be found in the Ubuntu documentation.
  2. If you are accessing your server over the internet, consider using a firewall such as UFW to restrict SSH access to specific IP addresses or networks.
  3. Regularly update your server to ensure that you have the latest security patches and fixes.


Remember to always keep your server and SSH configuration secure to prevent unauthorized access.