Skip to content

SSH

ssh-config stuff and how to log into a server

by anna koitschev and linnea kempf

  • if you want to login via windows10, you should use ubuntu a subsystem for linux.
  • if you are a mac-user, you shuld install iterm2

a quick introduction to ssh

  • ssh stands for "secure shell"
  • ssh is a safe encrytion method to ensure protectionwhile accessing a computer over a network. basically, it creates a secure channel for clients and remote servers to communicate safely
  • when using ssh, there are two kinds of "keys" that come into play for user authentication:
  • the private key is kept as a secret on the local machine. It is your personal key to the server
  • the public key is copied to the ssh server during the authentication process and locks the server shut. the private key can basically open the public key.
  • you can find information on how to install your personal public-private-key pair here in the wiki.

the .ssh folder

while creating your ssh keys, there are different files being created inside a folder called .ssh. this folder contains important information about your ssh key. In this folder you will find your private and public key, which allow you to securely enter remote servers like this one, known_hosts, a file listing all hosts to which the user has connected and the config file which allows users to define specific ssh configurations for different hosts.

a quick introduction to the ssh config file

  • the ssh config file is located inside your *.ssh folder* under the user's home directory
  • the ssh config file, or configuration file, is a text file containing all specifications of your ssh connection. it can be opened in any text editor.
  • ssh config files help configure the default values for ssh connections
to use a config file

you need:

  1. access to the terminal
  2. nano (a texteditor)
  3. a remote server

  • the default location of a user specific config file is in the .ssh directory:
  • ~/.ssh config
    
  • the systemwide configuration file for all users is in:
  • ~/etc/ssh/ssh_config
    
  • these file locations should not be changed!

how are ssh config files used?

if the ssh config file is in the right place, run the ssh command with the right settings to pick up what is in the config file and if an ssh config file contains an host section,you could see something like this:

host hfg-coding

    HostName hfg.lehrer.com
    User user vornamenachname
    IdentityFile ~/.ssh/id_name
the ssh command connects to the remote host:
ssh hfg-coding
the config file saves you from typing in connection details every time you want to connect to a host. you can set up default values for all servers or tweak settings for specific ones using a chain of host options and wildcards.


how to create a ssh config file

  • open your terminal and navigate to the .ssh directory:
  • cd ~/.ssh
    
    note: if the directory does not exist, you can create it by using mkdir like this:
    mkdir ~/.ssh
    
  • use a text editor to create and open the config file. in this case our text editor is nano:
  • nano config
    
  • the editor creates an open file for editing. you can now fill out the file with information, close and save the changes using these commands:
  • ctrl o
    ctrl x
    
  • give reding and writing permission to the current user only!
  • chmod 600 ~/.ssh/config
    
    there are many parameters that can be listed in a config file. config files follow a specific format to work correctly, so it´s important to follow it- this is how a configfile is bult:
    host hostname1
        parameter argument
        parameter argument
    host hostname2
        parameter argument
    
    [follow link for even more information!](https://phoenixnap.com/kb/ssh-config) ## *a compact explanation on locking into the server* after sucessfully installing your ssh-key, start the individual software on your laptop. --- **step 1**
    cd ~/.ssh
    
    type this command to change directory to the .ssh-folder which was crated when installing your ssh key. you are located inside the .ssh folder. --- **step 2 (optional!)**
    cat config
    
    this command will let you see the contents of the config file which is located inside your .ssh folder. you might need it to remember the name of your host!! after typing in step 2, you should be able to see something like this:
    host hfg-design_coding
            hostname hfg.lehrer.com
            user vorname-nachname
            identityfile ~/.ssh/privatname
    
    --- **step 3**
    ssh "host"
    
    this command will connect you to the remote host controlling our server. --- **step 4** you will now be asked to enter the password you made for your ssh key. after entering your password, you have succesfully entered the server! *it is very important to never forget your password!* ---- et voilà!