-
Notifications
You must be signed in to change notification settings - Fork 36
Git SSH setup
To generate key(s) you can run ssh-keygen -t ed25519 -C "[email protected]"
. You will then need to add the contents of the public key (.pub
) to your account's SSH Keys section on the relevent host (GitLab/GitHub).
In your .bashrc
, .zshrc
or equivalent add the following lines:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
Repeat the ssh-add
line for each private key you have, changing the filename as appropriate.
Copy the contents of this script snippet into your .bash_profile
, .bashrc
, .profile
or equivalent, this will ensure all your keys get loaded into the agent (and only one agent executable ever runs).
Note that the script assumes that all the keys are placed in ~/.ssh
and all their names end in _rsa
. If not, you will need to modify the script accordingly to load the right filenames.
sudo apt install keychain # Or the equivalent for your distro of choice
And add the following lines to ~/.bashrc
or ~/.zshrc
:
keychain --nogui $HOME/.ssh/*_rsa
source $HOME/.keychain/$HOSTNAME-sh # Under ZSH, the variable is just $HOST