Skip to content

ssh configuration

C'est pour faire quoi ?

TODOC

Create your ssh key

Very basic creation (rsa is required by git server):

ssh-keygen -t rsa

Tips: use -C to identify this public key for yourself or others.

Typically:

ssh-keygen -t rsa -b 4096 -C "${USER}@$(hostname)"

Public key default location: ~/.ssh/id_rsa.pub

If you need to create a ssh key in a script you need to use

ssh-keygen -t rsa -b 4096 -C "your comment" -f "${HOME}/.ssh/my_id_rsa" -N ''

You can use comment field to identify your keys, like this:

For default ssh key

You probally whant to use defaut file name for your key:

  ssh-keygen -t rsa -b 4096 -C "${USER}@${HOSTNAME}" -f "${HOME}/.ssh/id_rsa" -N ''

For a custom ssh key (design for a service, or any special use)

In that case it's a good idea to track service name, and user name of service, in key file name and in key comments:

APP_USER='testuser' # User for the application
APP_NAME='gitlab'   # Name of the application

ssh-keygen -t rsa -b 4096 -C "${APP_USER}_${APP_NAME}@${HOSTNAME}" -f "${HOME}/.ssh/${APP_USER}_${APP_NAME}_id_rsa" -N ''

Manage multiple ssh keys

You might need to add the key

eval `ssh-agent -s` # only once per session.

ssh-add [file ...]

To view know keys on your system, use:

ssh-add -l