rye Guy
rye Guy

Reputation: 33

public key denied in new terminal

I generated a ssh key and set it up on bitbucket and all was good but when I restarted my computer the key was now getting permission denied. I remade it and it failed again when I used a new terminal window. I'm on windows if that helps.

enter image description here

enter image description here

Upvotes: 2

Views: 318

Answers (1)

Prav
Prav

Reputation: 2884

This is normally happens based on what OS you're using and can be for a couple of reasons.

  1. Your shell/terminal don't initialize an SSH Agent at launch
  2. Your OS/terminal don't load the default private key at lunch
  3. There's also this edge case if you rename the private key it will no longer know how to load it.

The easiest fix is to add the following lines to your ~/.profile, ~/.bash_profile or ~/.zshrc.

eval $(ssh-agent) # create a agent for the shell
ssh-add ~/.ssh/id_rsa # this is one of the default file names, changes as required

Windows also support a similar way for Git Bash.

This should load your key to the shell at each lunch or tab.

Ps: If your private key has a password, it will prompt for you to type the password every time this runs.

This is what it would look like when you launch Git Bash

Agent pid 16516
Identity added: /c/Users/Praveen/.ssh/id_rsa (/c/Users/Praveen/.ssh/id_rsa)

Praveen@DESKTOP MINGW64 ~/Desktop
$

Upvotes: 1

Related Questions