Install SSH (Ubuntu, Kodibuntu), Connect with PuTTy (Windows)
WHAT IS SSH and PuTTy?
SSH is a server that will grant access to your computer remotely without any graphical interface. In other words, you will be able to connect to your linux computer with any other computers in your network via a terminal. Accessing your ssh from internet is not really recommended unless your secure your connection with a key as shown below.
PuTTy is a utility that mimic Linux terminal. If you want to remotely connect to Linux with a Linux computer, you won’t need PuTTy since you already have a Linux terminal. In Windows, there is no such things and this is why you will need something like PuTTy to get the job done.
Here is an example of PuTTy inside Windows connected to a Linux shell (Ubuntu):
INSTALL SSH (Ubuntu / Kodibuntu):
Kodibuntu comes with SSH server already installed out of the box, so you can skip #1.
- Open a terminal and type:
sudo apt-get install openssh-server
- create a back of your configuration file:
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.original
- To edit the configuration of your SSH server, open this file with sudo privilege:
sudo nano /etc/ssh/sshd_config
- You can leave everything to default and it will work well.
- Read the Manual of SSH for all the command references and descriptions:
man sshd_configor you can find online here: http://www.openssh.com/cgi-bin/man.cgi/OpenBSD-current/man5/sshd_config.5?&manpath=OpenBSD-current&query=sshd_config
- Once you’ve finish the configuration just restart the SSH Server with this command:
sudo /etc/init.d/ssh restart
INSTALL PuTTy (Windows):
Dowload the last windows build of PuTTy here PuTTy.exe:
- There is no installer just Launch it and enter the local ip address of the computer you want to connect to.
- Click Open:
- A terminal will appear. Just enter the remote computer login information and that’s it (You can use any of your linux users to remotely login). If no firewall is blocking you, you will be connected:
SECURE YOUR SSH/PuTTy Connection with a 2048bit RSA Key:
Connecting to your a SSH with a key will enhance the security by getting rid of the normal username/password login. You will be protected against brute force attack and in the meantime your ssh will be a little bit more secure.
Creating SSH Keys in windows:
- You will need another software from the same organisation: PuTTyGen.exe: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
- Hit Generate and randomly move your mouse in the blank area while the bar progress:
- Enter the key-phrase twice
- Save private (private_rsa2048_192.168.2.11.ppk) and public key (public_rsa2048_192.168.2.11.txt) in a folder you will remember. Keep this window open.
- Open PuTTy.exe, go under Connection->SSH->Auth and browse for your private key
- You save this as a preset in Session:
- Next click the Open Button
- A terminal window will appear and you will be prompt for username. Enter the linux username you want to connect with. The server will reject the key we installed in putty and this is normal. We didn’t install it yet.
- Create a folder in your home directory:
- Change permission so just user can write and read:
chmod 700 ~/.ssh
- Create a key file and Edit it:
- Copy the key from the PuttyKey Generator and paste it into the file:
- Save your file by quitting with
- Change permission for ready-only by this user:
chmod 400 ~/.ssh/authorized_keys2
- Re-open PuttY and load your config with the private key set in the parameters (Step 5). Now, you will be prompt for the passphrase you’ve entered in the Putty Key Generator:
- Get rid of the old username/password method by editing your ssh config:
sudo nano /etc/ssh/sshd_config
- Add / Modifiy these lines. It will disable password login and enable rsa and public key login:
#Disable Password: PasswordAuthentication no #Enable public / rsa keys: #(it should already be like this by default) RSAAuthentication yes PubkeyAuthentication yes
- Restart SSH:
sudo restart ssh
Stop Asking for Passphrase and Login only with Username:
You can set an automatic login with an agent that will inject the passphrase into PuTTy
- You will need another software from the same organisation: pageant.exe: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
- Launch pageant.exe. It will add an icon to the systray. Right-Click on it and choose View Keys
- Click on Add Key. Browse for your private key (private_rsa2048_192.168.2.11.ppk). You will be prompt for a passphrase: enter the one you typed in the PuTTy Key Generator and hit OK
- Close Window and open PuTTy
- Log in with your saved Session, enter your username and you should see something like this: