安装git for win

下载git for win 安装即可

配置sshd

进入git shell

# 配置hostkeys
cd /etc/ssh/
ssh-keygen.exe -t rsa -f ssh_host_rsa_key
ssh-keygen.exe -t dsa -f ssh_host_dsa_key
ssh-keygen.exe -t ecdsa -f ssh_host_ecdsa_key

# 配置日志目录
mkdir -p /var/log/

# 配置信任key, 在对应用户名下创建authorized_keys
/c/Users/win登录的用户名/.ssh/authorized_keys

配置自启动

# 
cat >/etc/profile.d/sshd.sh <EOF
check=`ps ax|grep sshd`
if [ -z "$check" ]; then
/usr/bin/sshd.exe -f /c/ProgramFiles/Git/etc/ssh/sshd_config -E /c/ProgramFiles/Git/var/log/sshd.log
fi
EOF

备注

这个ssh server 依赖git for win 的shell ,所以开机后需要先打开一个git_bash 窗口