Skip to content

SSH

Basically, SSH is a protocol which is used to establish a secure connection over a network Wikipedia (SSH).

For webprogramming SSH is used to:

  • Login to the terminal of a remote host. In our case the remote host is your Meise.
  • Copying files using a File Transfer Client (SFTP). Therefore, we utilize SFTP, which is the encrypted version FTP.
  • in case you use git, SSH is utilized for the push/pull operations.

Why do we need a personal private/public key

You can use SSH remote login and SFTP without setting your personal private/public key. You can use your credentials to remotely log in and SFTP connection to your Meise at any time. However, when logging in remotely, it is convenient if you don't have to enter your password when logging in. Additionally, your password could be compromised and your SSH private key may be more difficult to obtain. In case of GIT, push/pull operations either work using HTTPS or SSH as protocol. In case of SSH you need to store your

How to establish SSH-Key login

You will then find step-by-step instructions for Windows and Linux. Note that this is just a simple example for our purposes.

Create SSH Keys

Open a terminal in Windows or Linux and generate your puplic and private key using the command ssh-keygen:

username@mycomputer:~$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/username/.ssh/id_rsa
Your public key has been saved in /home/username/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:wHCjP1WMhB/jWcNC/pFRrXuAvMdW+bDzhwjDb1oR778 username@mycomputer
The key's randomart image is:
+---[RSA 3072]----+
|    . o+o+o...   |
|     =.o=.=o  .  |
|    . oooBoo.. . |
|     . o+.o.oo+  |
|      o S..o.+.+ |
|       .  = =o+ .|
|           *.o.+ |
|           .+ ..o|
|          .o   E+|
+----[SHA256]-----+

Now, your public and private key are available in a hidden folder .ssh in your home directory.

Copy public key

Next, we need to copy our public key to the remote host. Linux users can simply use the ssh-copy-id command:

username@mycomputer:~$ ssh-copy-id username@yourmeise.cosy.sbg.ac.at
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/username/.ssh/id_rsa.pub"
The authenticity of host 'beryourmeisegmeise.cosy.sbg.ac.at (IP)' can't be established.
ED25519 key fingerprint is SHA256:b4dfG5Ks1R1qrdjR5cijtngoRYAAH0jyyc/8PdEtVv0.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
username@yourmeise.cosy.sbg.ac.at's password: 
###

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'username@yourmeise.cosy.sbg.ac.at'"
and check to make sure that only the key(s) you wanted were added.

If you are using Windows or ssh-copy-id is not available, you can manually copy your public key to the appropriate file (~/.ssh/authorized_keys).

Therefore, you need to login to your meise. After you are logged in you can copy the content of your public file (~/.ssh/id_rsa.pub). Everyone should be able to open this file in an editor and to copy the content to the clipboard. Next, we place the content in ~/.ssh/authorized_keys:

username@meise:~$ cd .ssh
username@yourmeise:~/.ssh$ nano authorized_keys #Past clipboard content, save and exit nano
username@yourmeise:~/.ssh$ exit
logout
Connection to yourmeise.cosy.sbg.ac.at closed.
username@mycomputer:~$ ssh username@yourmeise.cosy.sbg.ac.at

In case your username on your computer and meise are the same you do not need to specify the username for the remote connection.