1

I have set up the ssh key for my laptop following the GitHub docs. Then I was having trouble pushing or pulling because I had to write the passphrase every time. So, I followed this GitHub doc. Added the below code to my .bash_profile

env=~/.ssh/agent.env

agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }

agent_start () {
    (umask 077; ssh-agent >| "$env")
    . "$env" >| /dev/null ; }

agent_load_env

# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2=agent not running
agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)

if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then
    agent_start
    ssh-add
elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then
    ssh-add
fi

unset env

Now I have to write the GitHub pass every time I turn on my computer. Is there any way so that I do not have to write that passphrase every time I reboot?

Joy Karmoker
  • 139
  • 13

1 Answers1

1

Reading man ssh-add, you can try and set SSH_ASKPASS, as described here.
Replace in your script ssh-add with:

cat ~/.ssh/id_rsa | SSH_ASKPASS=~/.print_ssh_password ssh-add -

This assume you have stored your private key passphrase in %USERPROFILE%\.print_ssh_password, which is not ideal, but at least protected in your own Windows profile folder.

The other approach, of course, is to remove the passphrase of your current existing private key (equally not ideal).
Then no more ssh-add.


The other obvious option is not have a passphrase in the first place when generating your private key.

You can also remove a passphrase to an existing private key.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250