To set up an OpenSSH server on Ubuntu 22.04, you will need to perform the following steps:
- Install the OpenSSH server package by running the following command:
sudo apt-get update
sudo apt-get install openssh-server
- Once the installation is complete, the SSH service will start automatically. You can check the status of the service by running:
systemctl status ssh
- If you want to start or stop the SSH service, you can use the following commands:
sudo systemctl start ssh
sudo systemctl stop ssh
- By default, the OpenSSH server listens on port 22. If you want to change the default port, you can do so by editing the file
/etc/ssh/sshd_config
and changing the value of thePort
directive. - Once you have made any necessary changes to the configuration file, you will need to restart the SSH service for the changes to take effect. You can do this by running the following command:
sudo systemctl restart ssh
- You can now connect to the OpenSSH server from a remote machine using a client such as
ssh
. For example, to connect to the server as the user “username” using the default port (22), you would run the following command:
ssh username@server_ip_or_hostname
- If you have changed the default port, you will need to specify the port number when connecting. For example, to connect to the server using port 2222, you would run the following command:
ssh -p 2222 username@server_ip_or_hostname
That’s it! You should now have a working OpenSSH server on your Ubuntu 22.04 machine.