我正试图在一台服务器机器上建立一个git存储库,该服务器可以通过互联网远程访问。
我已经成功地让git在本地/内部IP地址上工作。在本地局域网中,我有基于私钥的身份验证工作,为SSH (密码登录禁用),我可以克隆,推送,成功地使用Git和SSH,例如;
ssh USER@192.168.1.xxx
[-> accepts public key, gives me a remote console prompt as "USER", etc]
git clone git+ssh://USER@192.168.1.xxx//gitdir/project.git
[-> creates a local clone as desired, commits and push work, no problems seemingly]然而,我现在正试图以同样的方式通过外部/internet IP访问这台机器,我不明白它给了我什么行为。
对于直接的SSH登录,我得到以下内容(使用-v标志):
LOCALUSER@LOCALMACHINE:~$ ssh -v -i ~/.ssh/[PRIVATE_KEY] USER@[IP6_EXTERNAL_IP]
OpenSSH_7.4p1 Ubuntu-10, OpenSSL 1.0.2g 1 Mar 2016
debug1: Reading configuration data /home/[HOME]/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to [IP6_EXTERNAL_IP] [[IP6_EXTERNAL_IP]] port 22.
debug1: Connection established.
debug1: identity file /home/[HOME]/.ssh/[PRIVATE_KEY] type 4
debug1: key_load_public: No such file or directory
debug1: identity file /home/[HOME]/.ssh/[PRIVATE_KEY]-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4p1 Ubuntu-10
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4p1 Ubuntu-10
debug1: match: OpenSSH_7.4p1 Ubuntu-10 pat OpenSSH* compat 0x04000000
debug1: Authenticating to [IP6_EXTERNAL_IP] as 'USER'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
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:[SHA_HASH]
debug1: Host '[IP6_EXTERNAL_IP]' is known and matches the ECDSA host key.
debug1: Found key in /home/[HOME]/.ssh/known_hosts:4
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering ED25519 public key: /home/[HOME]/.ssh/[PRIVATE_KEY]
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: password
USER@[IP6_EXTRNAL_IP]'s password: ...and没有我提供的密码有效。我不知道服务器为什么要问密码,我在"sshd_config“中全局禁用密码登录,并且我已经三次检查这个用户是否也不例外。
当我试图通过外部IP (当然是通过SSH )从服务器克隆时,Git同样要求我的远程用户的密码,如果我执行以下操作来设置它以使用外部IP,而不是原始的本地IP:
git remote set-url origin ssh+git://USER@[REMOTE_IP]//gitdir/project.git如果你能帮助我理解我在这里所缺少的东西,我将不胜感激。
发布于 2017-08-09 22:25:09
弄明白了:
我不知道为什么,但我的系统不喜欢它,当我试图通过外部公共ip访问我的服务器,从我自己的局域网。我认为这是因为某种数据包混淆,因为本地机器和服务器机器通过路由器共享相同的公共ip (请确认这一点)。
当我试图从另一个网络连接时,事情就像预期的一样正常工作。我被要求要我的公钥,如果我没有提供正确的密码提示,立即拒绝,并且SSH和git通过SSH似乎在我改变我的回购源使用公共ip后在互联网上工作。编辑~/..ssh/config以设置关键标识和主机将涵盖任何进一步的细节。
标记问题解决了。谢谢。
https://stackoverflow.com/questions/45587384
复制相似问题