Windows下搭建git服务器
2016-10-09 17:45
190 查看
一、服务器端
安装Git
安装Copssh
说明
安装路径中不要出现空格,以免不必要的麻烦。比较安装到
我最终安装目录结构如下,仅供参考。
配置环境变量
右键单击“计算机”->选择“属性”->选择“高级系统设置”->在弹出的“系统属性”窗口中选择“高级”选择卡->单击下方的“环境变量”按钮->在弹出的“环境变量”窗口中找到“系统变量”->双击“Path”弹出“编辑系统变量”。在“变量值”中加入安装Git的如下路径:
注意路径之间以
配置Copssh
添加用户
测试ssh连接
可能出现的错误
解决办法
删除
如里出现以下提示:
输入
接下来输入密码后回车,看到
初始化仓库
二、客户端
安装Git
克隆远程仓库
密码方式
输入
输入密码
如果看到上述信息说明克隆成功。
常见错误
*错误1*
*错误2*
*解决办法*
写法很重要,仔细检查仓库路径是否正确。
*错误3*
*解决办法*
检查第3步中的环境变量是否配置正确,配置正确后重新启动
push到远程服务器
输入密码
可能出现以错误
解法办法
在服务器上执行以下命令:
或在.git/config文件后面添加如下代码:
公钥方式
上传公钥
修改Copssh配置
测试ssh连接
*常见错误*
加
多加几个加
*解决办法*
参考windows 下搭建git服务器,及问题处理。但仍然未解决,待续。。。
安装Git
安装Copssh
说明
安装路径中不要出现空格,以免不必要的麻烦。比较安装到
X:\Program Files\下的话,在路径中需要写为
/X/Program\ Files/。
我最终安装目录结构如下,仅供参考。
D |-Git |-Copssh SSH目录 |-Git Git目录 |-Kingsun 仓库目录
配置环境变量
右键单击“计算机”->选择“属性”->选择“高级系统设置”->在弹出的“系统属性”窗口中选择“高级”选择卡->单击下方的“环境变量”按钮->在弹出的“环境变量”窗口中找到“系统变量”->双击“Path”弹出“编辑系统变量”。在“变量值”中加入安装Git的如下路径:
D:\Git\Git\bin\ D:\Git\Git\mingw32\libexec\git-core\
注意路径之间以
;号分隔。
配置Copssh
添加用户
测试ssh连接
$ ssh git@196.1.1.12
可能出现的错误
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that a host key has just been changed. The fingerprint for the ECDSA key sent by the remote host is SHA256:uzpEC1KwT+29rcJaLqzfEiBXbpRWF1LYPHAmyFaYZ24. Please contact your system administrator. Add correct host key in /c/Users/Administrator/.ssh/known_hosts to get rid of this message. Offending ECDSA key in /c/Users/Administrator/.ssh/known_hosts:1 ECDSA host key for 196.1.1.12 has changed and you have requested strict checking. Host key verification failed.
解决办法
删除
C:\Users\Administrator\.ssh下的
known_hosts文件后重新尝试。
如里出现以下提示:
$ ssh git@196.1.1.12The authenticity of host '196.1.1.12 (196.1.1.12)' can't be established.
ECDSA key fingerprint is SHA256:uzpEC1KwT+29rcJaLqzfEiBXbpRWF1LYPHAmyFaYZ24.
Are you sure you want to continue connecting (yes/no)?
输入
yes继续,
Warning: Permanently added '196.1.1.12' (ECDSA) to the list of known hosts. git@196.1.1.12's password:
接下来输入密码后回车,看到
git@YFSERVER01 ~说明连接成功。可输入
$ exit退出连接。
初始化仓库
二、客户端
安装Git
克隆远程仓库
密码方式
输入
$ git clone ssh://git@196.1.1.12/kingsun/test.git并回车
Cloning into 'test'... git@196.1.1.12's password:
输入密码
remote: Counting objects: 3, done. remote: Total 3 (delta 0), reused 0 (delta 0) Receiving objects: 100% (3/3), done. Checking connectivity... done.
如果看到上述信息说明克隆成功。
常见错误
*错误1*
fatal: 'xxx' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
*错误2*
fatal: repository 'git@196.1.1.12/kingsun/test.git' does not exist
*解决办法*
写法很重要,仔细检查仓库路径是否正确。
$ git clone ssh://git@196.1.1.12/kingsun/test.git 正确 $ git clone ssh://git@196.1.1.12/d/kingsun/test.git 错误1 $ git clone git@196.1.1.12:22/kingsun/test.git 错误1 $ git clone git@196.1.1.12:kingsun/test.git 错误1 $ git clone git@196.1.1.12/kingsun/test.git 错误2
*错误3*
bash: git-upload-pack: command not found fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
*解决办法*
检查第3步中的环境变量是否配置正确,配置正确后重新启动
Openssh SSHD服务。然后再次尝试重新克隆。
push到远程服务器
$ git push origin master
输入密码
可能出现以错误
git@196.1.1.12's password: Counting objects: 3, done. Delta compression using up to 2 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 261 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) remote: error: refusing to update checked out branch: refs/heads/master remote: error: By default, updating the current branch in a non-bare repository remote: error: is denied, because it will make the index and work tree inconsistent remote: error: with what you pushed, and will require 'git reset --hard' to match remote: error: the work tree to HEAD. remote: error: remote: error: You can set 'receive.denyCurrentBranch' configuration variable t remote: error: 'ignore' or 'warn' in the remote repository to allow pushing int remote: error: its current branch; however, this is not recommended unless you remote: error: arranged to update its work tree to match what you pushed in som remote: error: other way. remote: error: remote: error: To squelch this message and still keep the default behaviour, se remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'. To ssh://git@196.1.1.12/kingsun/test.git ! [remote rejected] master -> master (branch is currently checked out) error: failed to push some refs to 'ssh://git@196.1.1.12/kingsun/test.git'
解法办法
在服务器上执行以下命令:
git config receive.denyCurrentBranch ignore
或在.git/config文件后面添加如下代码:
[receive] denyCurrentBranch = ignore
公钥方式
上传公钥
修改Copssh配置
测试ssh连接
$ ssh git@196.1.1.12
*常见错误*
Permission denied (publickey,keyboard-interactive).
加
-v参数
$ ssh git@196.1.1.12 -v
OpenSSH_7.1p2, OpenSSL 1.0.2d 9 Jul 2015
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to 196.1.1.12 [196.1.1.12] port 22.
debug1: Connection established.
debug1: identity file /c/Users/Administrator/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Administrator/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Administrator/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Administrator/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Administrator/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Administrator/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Administrator/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Administrator/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.8
debug1: match: OpenSSH_5.8 pat OpenSSH_5* compat 0x0c000000
debug1: Authenticating to 196.1.1.12:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr umac-64@openssh.com none
debug1: kex: client->server aes128-ctr umac-64@openssh.com none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:uzpEC1KwT+29rcJaLqzfEiBXbpRWF1LYPHAmyFaYZ24
debug1: Host '196.1.1.12' is known and matches the ECDSA host key.
debug1: Found key in /c/Users/Administrator/.ssh/known_hosts:1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /c/Users/Administrator/.ssh/id_rsa
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Trying private key: /c/Users/Administrator/.ssh/id_dsa
debug1: Trying private key: /c/Users/Administrator/.ssh/id_ecdsa
debug1: Trying private key: /c/Users/Administrator/.ssh/id_ed25519
debug1: Next authentication method: keyboard-interactive
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: No more authentication methods to try.
Permission denied (publickey,keyboard-interactive).
多加几个加
-v参数
$ ssh git@196.1.1.12 -vvv
OpenSSH_7.1p2, OpenSSL 1.0.2d 9 Jul 2015
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: ssh_connect: needpriv 0
debug1: Connecting to 196.1.1.12 [196.1.1.12] port 22.
debug1: Connection established.
debug1: identity file /c/Users/Administrator/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Administrator/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Administrator/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Administrator/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Administrator/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Administrator/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Administrator/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/Administrator/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.8
debug1: match: OpenSSH_5.8 pat OpenSSH_5* compat 0x0c000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to 196.1.1.12:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1
debug2: kex_parse_kexinit: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-ed25519,ssh-rsa
debug2: kex_parse_kexinit: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-md5-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-md5-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: kex_parse_kexinit: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: server->client aes128-ctr umac-64@openssh.com none
debug1: kex: client->server aes128-ctr umac-64@openssh.com none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:uzpEC1KwT+29rcJaLqzfEiBXbpRWF1LYPHAmyFaYZ24
debug1: Host '196.1.1.12' is known and matches the ECDSA host key.
debug1: Found key in /c/Users/Administrator/.ssh/known_hosts:1
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /c/Users/Administrator/.ssh/id_rsa (0x2005f150),
debug2: key: /c/Users/Administrator/.ssh/id_dsa (0x0),
debug2: key: /c/Users/Administrator/.ssh/id_ecdsa (0x0),
debug2: key: /c/Users/Administrator/.ssh/id_ed25519 (0x0),
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /c/Users/Administrator/.ssh/id_rsa
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Trying private key: /c/Users/Administrator/.ssh/id_dsa
debug1: Trying private key: /c/Users/Administrator/.ssh/id_ecdsa
debug1: Trying private key: /c/Users/Administrator/.ssh/id_ed25519
debug2: we did not send a packet, disable method
debug1: Next authentication method: keyboard-interactive
debug2: userauth_kbdint
debug2: we sent a keyboard-interactive packet, wait for reply
debug1: Authentications that can continue: publickey,keyboard-interactive
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey,keyboard-interactive).
*解决办法*
参考windows 下搭建git服务器,及问题处理。但仍然未解决,待续。。。
相关文章推荐
- Windows下搭建和配置Subversion服务器(CollabNetSubversion-server-1.5.4-1.win32.)
- SSH+Git Server on Windows - 在Windows下搭建Git服务器
- Ubuntu 10.10搭建git服务器
- windows 下 git 服务器的 搭建
- Windows下搭建Subversion 服务器(转)
- Windows下搭建Subversion 服务器
- CentOS下搭建Git服务器Gitosis
- Windows上使用Cygwin和Gitolite搭建Git服务器
- 在ProjectLocker上搭建自己的GIT服务器
- ubutu11.04上搭建git服务器
- Fedora 12 ftp,http及GitWeb服务器搭建(网页版)
- Ubuntu中Git服务器搭建
- Windows上搭建Git服务器
- Windows上搭建Git服务器详细教程(TortoiseGit + msysgit + CopSSH + WindowsXP )
- (转)Ubuntu中Git服务器搭建
- Git服务器在Ubuntu中的搭建
- CruiseControl 安装 配置 教程 实例 搭建服务器 (CruiseControl + git/svn)
- ubuntu 服务器搭建,bugzilla,git安装配置
- git服务器搭建
- RHEL下搭建GIT服务器