Generating a new SSH key and adding it to the ssh-agent

Posted under » Linux on 24 April 2021

If you don't already have an SSH key, you must generate a new SSH key.

$ ssh-keygen -t ed25519 -C "your_email@example.com"
> Enter a file in which to save the key (/home/anoneh/.ssh/id_ed25519): [Press enter]

Note -t ed25519 is a type of encryption. You can specify the name later eg. waklu. However if you just press enter it will save to your .ssh folder. If you did specify, it will go the folder you are currently at and you have to put it to your .ssh file which is troublesome. Best to just enter.

After pressing enter, at the prompt, type a secure passphrase.

If you're unsure whether you already have an SSH key, check for existing keys.

$ ls -al ~/.ssh

If you don't want to reenter your passphrase every time you use your SSH key, you can add your key to the SSH agent, which manages your SSH keys and remembers your passphrase.

Start the ssh-agent in the background and add your SSH private key to the ssh-agent. If you created your key with a different name, replace waklu in the command with the name of your private key file.

$ eval "$(ssh-agent -s)" // start
$ ssh-add ~/.ssh/waklu

Use this to adding a new SSH key to your GitHub account.

web security linux ubuntu python django git Raspberry apache mysql php drupal cake javascript css AWS