• 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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 06, 2018 in Bitbucket

Do you use Bitbucket Cloud and Jira Cloud? If so, let us know!

Hi Community, I'm Julia and I'm on the Jira Software Cloud marketing team!  We're looking for companies or teams using Bitbucket Cloud and Jira Software Cloud. If your team fits the t...

145 views 6 3
Join discussion

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