Tuesday, December 15, 2009

How to install OpenSSH in Ubuntu to connect to another computer

OpenSSH encrypts all traffic including passwords to effectively eliminate connection hijacking or eavesdropping on the traffic. SSH was designed as a replacement for Telnet,rlogin and rsh, which send information, notably passwords in plaintext leaving them open for interception. OpenSSH provides secure tunneling capabilities and several authentication methods, and supports all SSH protocol versions.
This will all be done in Terminal.

Type the following two commands to install both ssh client and server:

sudo apt-get install openssh-server openssh-client

You can do the same for the other pc or just install openssh-server if the pc is just going to be a server.
To log in you would do the following:

ssh yourusername@remotepc (ex. ssh bob@ if the two computers have the same username you can just do ssh
you will see a message like this
Host key not found from database.Key fingerprint:xezop-fomas-lifot-pisoc-zyvik-hutoz-bafaf-zapyc-lubev-riked-dexax
You can get a public key's fingerprint by running% ssh-keygen2 -F publickey.pub on the keyfile.
Are you sure you want to continue connecting (yes/no)

Type yes and it will add the RSA key this will only happen once, that is it. By default OpenSSH will be listening on port 22 but I would change that to a port of your choice for security since a network port scanner like Nmap can be ran by intrudes.
The configuration file is in /etc/ssh/sshd_config
we can use gedit to modify this:
sudo gedit /etc/ssh/sshd_config you will see #Port 22 remove the # and change the port number to something like 3787, now save the changes.
Now since we changed the port number the command to use ssh will be ssh -p222 (-p tells ssh what port to use)
Other commands that can be used if needed are:
  To stop server:
sudo /etc/init.d/ssh stop

  To start server:
sudo /etc/init.d/ssh stop

 To restart server:
sudo /etc/init.d/ssh restart
SSH is one of my favorite programs. I would advise to look at the man pages by typing man ssh to view all the options.


Post a Comment


Shaun Mallette's Blog Design by Insight © 2009