Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I need to run `ssh-add` in my Powershell profile?

In my Microsoft.PowerShell_profile.ps1 document, I've had to add ssh-add ~/.ssh/github_rsa following the poshgit examples in order for it to connect to my GitHub repos.

# Load posh-git example profile
. 'C:\tools\poshgit\dahlbyk-posh-git-8aecd99\profile.example.ps1'

ssh-add ~/.ssh/github_rsa

If I don't have that in my profile, I Github gives me permissions errors when I try to connect.

If I do it manually, it will work for the entire duration of my desktop session, but as soon as I reboot my computer, I need to re-run the command.

Why doesn't poshgit and ssh-add remember the rsa that I've added? It seems wrong to have to re-add it every time.

like image 399
Chase Florell Avatar asked Sep 06 '13 16:09

Chase Florell


1 Answers

It's because your rsa key is not the default name ( id_rsa ) so you either need to use ssh-add (which adds it to a running service that remembers the key decrypted with your passphrase) or just add an entry into your ~\.shh\config

~\.ssh\config (create or edit):

Host github.com
    HostName github.com
    User git
    IdentityFile ~/.ssh/github_rsa

Or, if github is the only thing you use ssh keys for, just rename the key to id_rsa and then git (well ssh.exe) will find it for you automatically AND poshgit will ssh-add it for you (to handle passphrases).

like image 132
Luggage Avatar answered Oct 24 '22 21:10

Luggage