I am using Github for Windows on Windows 7. I have a bash script to add the ssh-key to my ssh-agent. I have setup a ssh remote repo.
add_key.sh
#!/bin/bash
cd ../ssh/
eval $(ssh-agent)
ssh-add id.rsa
cd ../htdocs/
Execute command-
./add_key.sh
It returns
Agent pid 5548
Identity added: id.rsa (id.rsa)
When I git push origin master, it fails. But when I manually cd in the ssh directory, and run the same ssh-related commands and cd back to my directory htdocs and git push to origin master, it works.
Why is this happening?
git pushfrom? Some other shell session? Does that shell-session have thessh-agentenvironment options set correctly?./sourceto run that "script" or are you using./script.sh? Because the latter means yourgit pushcannot be in the same session as that script runs in its own shell session./path/to/script.shstarts a new shell. Using. /path/to/script.shuses the current shell./path/to/script.sh. Your path just happens to be./. You want. add_keyor. ./add_key. Note the space.