openSSH server on ubuntu (hardy)

open up a Terminal window, and use apt-get to download and install OpenSSH Server:

sudo apt-get install openssh-server

Once the installation is finished. We’ll need to make a few changes to your sshd_config file in order to increase SSH’s security. To edit your your sshd_config file, use the following command:

sudo gedit /etc/ssh/sshd_config

(Note that you can use your editor of choice instead; vi or emacs or whatever. when I’m at my desktop I use gedit if I’m running through command line its always nano but its up to you what you want to use.)

Once you’re editing the file, we’ll need to change the following directives:

PermitRootLogin no

Never, ever give root access to SSH unless you have an extremely good reason for doing so.

The default port is 22, you can change this if you want some people will say yes change it, its really up to you.

You may also want to change the AllowUsers directive, which specifies which users can access SSH. For example, to restrict access to only the users b4d455 and billybob:

AllowUsers b4d455 billybob

Once you’ve finished changing your settings, save your changes, and restart the SSH daemon:

sudo /etc/init.d/ssh restart

You should now be able to SSH into your Ubuntu machine. You can do so from the Terminal on another Linux machine, through cgywin, or by using Putty on a Windows machine.

Advertisements