Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
lecture
lecture
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • pt1_hs20
  • lecturelecture
  • Wiki
  • ssh_config

Last edited by rworreby Oct 07, 2020
Page history

ssh_config

SSH Configs

When you start to work with multiple remote servers you may run into problems.
This is because your computer does no longer know which ssh-key to provide for which server.
But don't you worry! ssh config to the rescue.
A ssh .ssh/config file can help you to manage multiple ssh-keys and is simply a text file (without .txt extension) where each remote is specified like this:

Host aliases
   HostName hostname
   User username
   IdentityFile .ssh/keyname
  • alias is an alias that you may specify i.e. in order to ssh into remote servers.
  • hostname is the name of the server i.e. gitlab.ethz.ch
  • User is your gitlab username i.e. for gitlab.ethz.ch it is you nethz username.
  • IdentityFile is the path to you local private ssh key i.e. .ssh/id_rsa

Creating A config file

  1. Change into your home directory: cd
  2. Change into your ssh directory: cd .ssh
  3. Create a ssh config file: touch config
  4. Edit the ssh config file as fit
    Sidenote: when using multiple ssh keys its best to give them descriptive names when creating them i.e. id_rsa_gitlab_ethz

Using Git after setting up a config file

If you provide an alias to a Host in your git config file you need to access this host with the same alias.

Host gitlab_account_1
   HostName gitlab.ethz.ch
   User username
   IdentityFile ~/.ssh/id_rsa_ethz

cloning the repo is then: $ git clone git@gitlab_account_1:pt1_hs20/lecture.git

If you only have one account to a server it is recommended to not give an alias (use the same for Host as for HostName).

Host gitlab.ethz.ch
   HostName gitlab.ethz.ch
   User username
   IdentityFile ~/.ssh/id_rsa_ethz

Cloning the repo is then: $ git clone git@gitlab.ethz.ch:pt1_hs20/lecture.git

Clone repository
  • exercise02
  • exercise03
  • exercise09
  • git ssh
  • Home
  • ssh keys
  • ssh_config