Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
  • Community
  • Products
  • Bitbucket
  • Questions
  • When setting up SSH for git, after editing .bashrc, I get a bash message stating there is no environment file in my .ssh folder. Yet I have one. What could be the issue?

When setting up SSH for git, after editing .bashrc, I get a bash message stating there is no environment file in my .ssh folder. Yet I have one. What could be the issue?

Nick T February 19, 2016

To start off, I am on the 64-bit version of Windows 10.

After positing the follow code into my .bashrc file:

SSH_ENV=$HOME/.ssh/environment
  
# start the ssh-agent
function start_agent {
    echo "Initializing new SSH agent..."
    # spawn ssh-agent
    /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
    echo succeeded
    chmod 600 "${SSH_ENV}"
    . "${SSH_ENV}" > /dev/null
    /usr/bin/ssh-add
}
  
if [ -f "${SSH_ENV}" ]; then
     . "${SSH_ENV}" > /dev/null
	 ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
	    start_agent;
	}
else
    start_agent;
fi

And then restarting Git Bash, I get a bash message stating:

bash: [-f/c/Users/<user>/.ssh/environment]: No such file or directory
Initializing new SSH agent...
succeeded
bash: ./c/Users/Nick/.ssh/environment: No such file or directory
Could not open a connection to your authentication agent.

When I check ~/.ssh I see I have the 'environment' in there. The file's contents are:

SSH_AUTH_SOCK=/tmp/ssh-YPNbq3XWRqJ8/agent.10808; export SSH_AUTH_SOCK;
SSH_AGENT_PID=7904; export SSH_AGENT_PID;
#echo Agent pid 7904;

I'm guessing the script is trying to find /dev/null or /usr/bin/ssh-add and failed. Neither of those are located in my $HOME directory. I'm guessing those paths are for setting up SSH for Git on linux as well. Should I be pointing to another directory? Thanks in advance.

1 answer

0 votes
Bibi De Carli November 20, 2016

Add this code to .bash_profile worked for me.
From http://stackoverflow.com/questions/18880024/start-ssh-agent-on-login 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events