SSH keys/en

SSH keys are necessary to login to the and  servers to push code to.

Generating a new SSH key
Follow the instructions below to create one if you do not already have one in. To make sure whether you need to generate a brand new key, let's check if an SSH key already exists on your system. Run this command in a terminal:

The command will list the files that are in the (hidden)  directory. If the directory already exists on your system and if the output lists a file called, then you can go directly to #Copy your SSH Public key.

To generate a new SSH key, open a terminal then enter the command below and replace with your own email address. We want the default settings so when asked to enter a file in which to save the key, just press Enter.

Enter a strong and unique passphrase and press the Enter key.


 * Why do passphrases matter?


 * Passwords aren’t very secure. If you use one that’s easy to remember, it’s easier to guess or brute-force. If you use one that’s random it’s hard to remember, so you might write the password down. Both are very bad. This is why you’re using ssh keys. But using an ssh key without a passphrase is basically the same as writing down that random password in a file on your computer. Anyone who gains access to your drive has gained access to every system you use that key with. That's why you also add a passphrase. To not enter a long passphrase every time you use the key, there’s a tool called . It can save your passphrase securely. If you use macOS or Linux, then your keys can be saved in the system’s keychain to make your life even easier.

The  command will create 2 files in   directory:


 * - your private SSH key (for identification)
 * - your public SSH key

Copy your SSH Public key
Get the content of your public key file (e.g. ) to copy it to your clipboard:

One option is to open your public key file with your favorite text editor (Notepad, TextEdit, gedit, etc.). In the file chooser dialog of your text editor, you may need to turn on “View hidden files” to find the file, because the  directory is hidden. Sometimes the “View hidden files” option is available by right-clicking in the file chooser dialog.

Other options are:


 * On Linux, run and manually copy the output to the clipboard.
 * On Windows, you can open Git GUI, go to Help 🡒 Show Key, and then press "Copy To Clipboard" to copy your public key to your clipboard.
 * On macOS, you can run to copy the contents of the your public key file to your clipboard.

It’s important you copy your SSH Public key exactly as it is written, without adding any newlines or whitespace. Copy the full text, including the "ssh-ed25519" prefix, the key itself, and the email address suffix.

Linux
Start the Git Bash command line.


 * Get ssh-agent running using
 * Be sure to use the accent, not the single quote  . (You could copy and paste from this page if you cannot easily enter this special character.) Note also that if you are using an alternative shell in Linux (for example the Fish shell), this command may not work; switching to Bash will fix the issue.
 * Be sure to use the accent, not the single quote  . (You could copy and paste from this page if you cannot easily enter this special character.) Note also that if you are using an alternative shell in Linux (for example the Fish shell), this command may not work; switching to Bash will fix the issue.


 * Add your private key to the agent. If you followed the steps above and your key has the default name, then the command is:

macOS
For macOS see CodeX article.

Windows
First install OpenSSH on Windows.

Open PowerShell as an administrator and run this to set the  to start automatically every time you start the shell.

Then start the ssh agent service

Verify it is running

Load your key into the ssh-agent

Now, every time you open PowerShell, you will be logged into the git server automatically and can start running git commands without requiring you to sign in.