Reputation: 33
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.
Upvotes: 2
Views: 318
Reputation: 2884
This is normally happens based on what OS you're using and can be for a couple of reasons.
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