• 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?

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 21, 2018 in Bitbucket

Branch Management with Bitbucket

As a project manager, I have discovered that different developers want to bring their previous branching method with them when they join the team. Some developers are used to performing individual wo...

2,325 views 9 12
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you