让ssh-agent使用从Windows命令shell运行的git [英] Getting ssh-agent to work with git run from windows command shell
问题描述
我使用OpenSSH安装了msysgit。我正在连接到一个gitosis回购。从git bash中,我创建了一个 .profile
文件,该文件在每次打开git bash时运行ssh-agent(如果尚未运行),使用此脚本
I have msysgit installed, with OpenSSH. I am connecting to a gitosis repo. From the git bash, I have created a .profile
file that runs ssh-agent (if not already running) each time git bash is opened, using this script
SSH_ENV=$HOME/.ssh/environment
function start_agent {
echo "Initialising new 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;
}
# Source SSH settings, if applicable
if [ -f "${SSH_ENV}" ]; then
. ${SSH_ENV} > /dev/null
#ps ${SSH_AGENT_PID} doesn't work under cywgin
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
start_agent;
}
else
start_agent;
fi
我也使用git扩展,它从Windows命令运行git命令提示,而不是git bash。所以,ssh没有看到正在运行的ssh-agent。是否有可能解决这个问题?
I am also using git extensions, which runs the git command from the Windows command prompt, not git bash. So, ssh doesn't see the ssh-agent that is running. Is it possible to fix this?
推荐答案
我遇到同样的问题,然后尝试添加此代码
I had the same problem as you, then I tried adding this code
#! /bin/bash
eval `ssh-agent -s`
ssh-add ~/.ssh/*_rsa
放入我的主目录中的文件 .bashrc
。它的工作原理!
into file .bashrc
in my home directory. And it works!
这篇关于让ssh-agent使用从Windows命令shell运行的git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!