Setting up SSH Server on local machine – Ubuntu

There is way where a local machine can be accessed using ssh once you install OpenSSH.  Both the host (server) and Client must be in the same local network.

sudo apt-get install openssh-server

This will install Openssh-server. Before configuring it is always a good practice to backup the default config file.

sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.factory-defaults

Once this is done, change the port number to somewhere in the 20K -60K range. This is done keeping the security in mind. Somebody trying to gain access will use the default port (22). If it’s not 22, then it is hard to try anf go through all the 60K ports.

sudo nano /etc/ssh/sshd_config

Add the following line to restrict access only to certain users

AllowUsers YourUserName

This will only allow access to you,.

Press Ctrl-O to save and Ctrl-X to quit.

Restart the server

sudo restart ssh

Now, test your server by accessing it.

sudo -v username@host_ip_address -p PortNo

Well, PortNo is the port number in the config file. Username is the username of the local machine where you set up ssh-server. To find out the ip address of the local machine use the following command.


This should give you the details about your internet connection and your local ip address.

To login, the prompt will ask for the password.

In any other machine on the same local network use the following to connect to the ssh-server

ssh -X username@host_ip -p PortNo

That’s it from this post.


There is much more detailed article on the Ubuntu Documentation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.