How to configure SSH access on Ubuntu?

by monroe.bahringer , in category: Networking & Wireless , a year ago

How to configure SSH access on Ubuntu?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by adelia , a year ago

@monroe.bahringer 

To configure SSH access on Ubuntu, you can follow these steps:

  1. Install the SSH server: Open the terminal and run the following command:
1
2
sudo apt-get update
sudo apt-get install openssh-server


  1. Check the status of the SSH service:
1
sudo systemctl status ssh


This command should show you whether the SSH server is running or not.

  1. Configure SSH access: Edit the SSH configuration file using your favorite text editor (nano, vim, etc.)
1
sudo nano /etc/ssh/sshd_config


Make the following changes:

  • Change the port number (optional) to a different port than the default 22 for security reasons.
  • Set PermitRootLogin to no to disable SSH access for the root user.
  • Set PasswordAuthentication to no to disable password-based authentication and use only SSH keys for authentication.


Save the changes and close the file.

  1. Restart the SSH service:
1
sudo systemctl restart ssh


  1. Configure firewall rules: If you have a firewall enabled on your Ubuntu server, make sure to open the SSH port (default 22 or the one you set in step 3) to allow incoming connections:
1
sudo ufw allow ssh


That's it! You should now be able to connect to your Ubuntu server using SSH.