在云服务器上搭建git服务器遇到的问题及解决

使用了将近一年的腾讯云服务器了,学生价很是公道。但是今天遇到了一个极其纠结的问题,在部署git服务器的时候,始终无法使用ssh公钥密钥配对从而免密码连接(之间我一直使用的是ssh ubuntu@ip 然后输入密码的方式连接的)。

服务器上除了默认的ubuntu用户我还加入了一个git用户,在ssh -v git@ip登陆的时候打印的信息如下:

D:\github> ssh  -v git@123.206.85.122
OpenSSH_7.3p1, OpenSSL 1.0.2j  26 Sep 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 1: Applying options for *
debug1: Connecting to 123.206.85.122 [123.206.85.122] port 22.
debug1: Connection established.
debug1: identity file /c/Users/hongl/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/hongl/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/hongl/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/hongl/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/hongl/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/hongl/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/hongl/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/hongl/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.1
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.1 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 123.206.85.122:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:1aJYXhw/rqhK0D0SweH6wzaVOZ73HE6fDbrZBZgxi60
Warning: Permanently added '123.206.85.122' (ECDSA) to the list of known hosts.
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /c/Users/hongl/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /c/Users/hongl/.ssh/id_dsa
debug1: Trying private key: /c/Users/hongl/.ssh/id_ecdsa
debug1: Trying private key: /c/Users/hongl/.ssh/id_ed25519

然后是让输入密码登陆,可是的我的公钥已经放在了/home/git/.ssh/authorized_key,纠结了半天时间。请稍安勿躁,重启改权限各种搞都不行,还是原来的配方还是熟悉的味道,同样的方法在联通云服务器上就好使了。第二早上又试了一下腾讯云,奇迹般地又好使了。真的是莫名其妙。

修改了/ect/passwd中git用户的权限之后,在使用android studio连接git服务器的时候经常会抛出一个这样的异常

IOException: 远程主机强迫关闭了一个现有的连接。
无须担心,这个是当你不想让别人直接登录操作你的git服务器,所以你将/ect/passwd中git用户权限从/bin/bash修改成了/usr/bin/git-shell,这时在客户端尝试连接服务器的时候,服务器会限制客户端登录服务器,但是git服务功能还可以正常使用。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值