Step 1: Check for SSH keys
First, we need to check for existing SSH keys on your computer. Open up your Git Bash and type:
ls -al ~/.ssh # Lists the files in your .ssh directory, if they exist
Check the directory listing to see if you already have a public SSH key. The default public key file names are:
- id_dsa.pub
- id_ecdsa.pub
- id_ed25519.pub
- id_rsa.pub
Step 2: Generate a new SSH key
To generate a new SSH key, copy and paste the text below, making sure to substitute in your email address. The default settings are preferred, so when you’re prompted to “Enter a file in which to save the key”, just press Enter to continue.
ssh-keygen -t rsa -C "your_email@domain.com" # Creates a new ssh key, using the provided email as a label # Generating public/private rsa key pair. # Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press enter]
Next, you’ll be asked to enter a passphrase.
# Enter passphrase (empty for no passphrase): [Type a passphrase] # Enter same passphrase again: [Type passphrase again]
Which should give you something like this:
# Your identification has been saved in /c/Users/you/.ssh/id_rsa. # Your public key has been saved in /c/Users/you/.ssh/id_rsa.pub. # The key fingerprint is: # 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@accedo.tv
Then add your new key to the ssh-agent:
# start the ssh-agent in the background. In windows use eval.
eval `ssh-agent -s`
# Agent pid 59566 ssh-add ~/.ssh/id_rsa
Step 3: Add your SSH key to your account
Run the following command to copy the key to your clipboard. Keep in mind that your key may also be named id_dsa.pub
, id_ecdsa.pub
or id_ed25519.pub
.
clip < ~/.ssh/id_rsa.pub # Copies the contents of the id_rsa.pub file to your clipboard
Alternatively, using your favorite text editor, you can open the public key file and copy the contents of the file manually.
git config –global user.name “Firstname Lastname” git config –global user.email “email@domain.com”