Ubuntu Linux OpenSSH

I just installed Ubuntu 9.10 (the Karmic Koala, as they call it) at my home Desktop. First thing I tried was to check whether my ssh daemon was running, and it wasn't. I did have the ssh client but not the scripts to start the server, but no panic. It is quite fast to fix this. Jut open a terminal window and type the following to install OpenSSH.

sudo apt-get install openssh-server openssh-client


I did not need the client as I had it installed already. Here is the result from the command above:

dambrosio@Sepultura:~$ sudo apt-get install openssh-server openssh-client
Reading package lists... Done
Building dependency tree       
Reading state information... Done
openssh-client is already the newest version.
The following packages were automatically installed and are no longer required:
  linux-headers-2.6.31-14 linux-headers-2.6.31-14-generic
Use 'apt-get autoremove' to remove them.
Suggested packages:
  rssh molly-guard openssh-blacklist openssh-blacklist-extra
The following NEW packages will be installed:
  openssh-server
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 286kB of archives.
After this operation, 766kB of additional disk space will be used.
Get:1 http://br.archive.ubuntu.com karmic/main openssh-server 1:5.1p1-6ubuntu2 [286kB]
Fetched 286kB in 0s (561kB/s)      
Preconfiguring packages ...
Selecting previously deselected package openssh-server.
(Reading database ... 137899 files and directories currently installed.)
Unpacking openssh-server (from .../openssh-server_1%3a5.1p1-6ubuntu2_i386.deb) ...
Processing triggers for ureadahead ...
ureadahead will be reprofiled on next reboot
Processing triggers for ufw ...
Processing triggers for man-db ...
Setting up openssh-server (1:5.1p1-6ubuntu2) ...
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
 * Restarting OpenBSD Secure Shell server sshd                                                                               [ OK ] 


Now, check if the client and server were correctly installed by trying to ssh connect to your own machine, by typing "ssh -C localhost" - the -C option stands for Compression, which speeds up transmission:

dambrosio@Sepultura:~$ ssh -C localhost
The authenticity of host 'localhost (::1)' can't be established.
RSA key fingerprint is e7:4f:9d:54:4f:75:71:1d:8c:d1:e6:83:34:33:46:87.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
dambrosio@localhost's password: 


That's it! You've got ssh running on your desktop as a server.
Let's say now that you want to change the port where SSH listens to. I need to do this, because at work I am only allowed to use ports 80 and 443. So, in order to be able to ssh to my home machine from work, I wanted to change ssh to run at port 443 instead of the default 22. To accomplish this, first change the config file:

dambrosio@Sepultura:~$ sudo vi /etc/ssh/sshd_config


Find the line that tells sshd which port to run on and change it to whatever you like. In my case, I changed it to 443. Actually I simply added another port on which sshd will listen for.

# What ports, IPs and protocols we listen for
Port 22 
Port 443


Now, restart the server:

dambrosio@Sepultura:~$ sudo /etc/init.d/ssh restart


Or stop and start it:

dambrosio@Sepultura:~$ sudo /etc/init.d/ssh stop
dambrosio@Sepultura:~$ sudo /etc/init.d/ssh start


Now I can connect to 443 or 22 and sshd will recognize them:

dambrosio@Sepultura:~$ ssh -p 443 localhost
dambrosio@localhost's password: