无法通过docker容器中的ssh获取任何内容

时间:2019-02-23 15:53:09

标签: docker ssl iptables

我有一台远程计算机。该机器可以运行docker容器。 Docker版本是:

    <%= form_for([@listing, @order]) do |form| %>
   <% if order.errors.any? %>
   <div id="error_explanation">
     <h2><%= pluralize(order.errors.count, "error") %> prohibited this order   from being saved:</h2>

  <ul>
  <% order.errors.full_messages.each do |message| %>
    <li><%= message %></li>
  <% end %>
  </ul>
    </div>
  <% end %>


    <div class="form-group">
   <%= form.label :name %>
    <%= form.text_field :name, class:"form-control" %>
 </div>

 <div class="form-group">
   <%= form.label :size %>
   <%= form.text_field :size, class:"form-control" %>
 </div>

<div class="form-group">
<%= form.label :mobile %>
<%= form.text_field :mobile, class:"form-control" %>
 </div>

  <div class="form-group">
   <%= form.label :city %>
   <%= form.text_field :city, class:"form-control" %>
  </div>    

 <div class="form-group">
   <%= form.label :address %>
   <%= form.text_field :address, class:"form-control" %>
 </div>

 <div class="form-group">
   <%= form.label :PinCode %>
   <%= form.text_field :PinCode, class:"form-control" %>
  </div>
<div class="form-group">
  <%= form.label :Landmark %>
  <%= form.text_field :Landmark, class:"form-control" %>
  </div>



  <div class="form-group">
    <%= form.label :Description %>(if any special changes)
    <%= form.text_field :Description, class:"form-control" %>
 </div>

 <div class="form-group">
   <%=form.submit%>
   <%=link_to "Checkout" %>
 </div>




   <button  type="submit"    onClick="placeOrder(this.form)" class="button button2">  

<!-- Set up a container element for the button -->
<div id="paypal-button-container"> </div>

<!-- Include the PayPal JavaScript SDK -->
<script src="https://www.paypal.com/sdk/js?client-id=sb&currency=USD"></script>

<script>
    // Render the PayPal button into #paypal-button-container
    paypal.Buttons({

        // Set up the transaction
        createOrder: function(data, actions) {
            return actions.order.create({
                purchase_units: [{
                    amount: {
                        value: '0.01'
                    }
                }]
            });
        },

        // Finalize the transaction
        onApprove: function(data, actions) {
            return actions.order.capture().then(function(details) {
                // Show a success message to the buyer
                alert('Transaction completed by ' + details.payer.name.given_name + '!');
            });
        }





    }).render('#paypal-button-container');


</script>


    <%=form.submit%>
       Place Order</button>

我运行了安装了ssh密钥的docker容器。当我尝试从github克隆项目时,Client: Version: 18.09.0 API version: 1.39 Go version: go1.10.4 Git commit: 4d60db4 Built: Wed Nov 7 00:48:57 2018 OS/Arch: linux/amd64 Experimental: false 挂起。

git clone

但是有趣的部分是:我可以在本地运行相同的容器,运行dev@d35e8c742186:~$ git clone git@gitlab.com:user/node-modules/my-project.git Cloning into 'my-project'... remote: Enumerating objects: 121, done. remote: Counting objects: 100% (121/121), done. ,一切都会好起来,我可以克隆项目

本地计算机上的Docker:

git clone

也许有一些网络问题?如何调试这种情况?

更新 我得到不同的输出,但是Client: Version: 18.06.1-ce API version: 1.38 Go version: go1.10.3 Git commit: e68fc7a Built: Tue Aug 21 17:24:56 2018 OS/Arch: linux/amd64 Experimental: false 仍然挂起

git clone

更新2

Cloning into 'my-project'...
remote: Enumerating objects: 121, done.
remote: Counting objects:  58% (71/121) 

更新3 一切都在另一台远程计算机上运行。我真的相信存在一些网络问题,而不是docker问题或git

更新4 我认为我遇到了与SSL certificate verification fails inside docker container on specific server

相同的问题

这是服务器的 iptables规则:

Cloning into 'my-project'...
OpenSSH_7.2p2 Ubuntu-4ubuntu2.6, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "gitlab.com" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to gitlab.com [35.231.145.151] port 22.
debug1: Connection established.
debug1: identity file /home/dev/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/dev/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/dev/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/dev/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/dev/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/dev/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/dev/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/dev/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.6
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.7
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.7 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to gitlab.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: 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,ext-info-c
debug2: host key algorithms: 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,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc
debug2: MACs ctos: 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
debug2: MACs stoc: 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
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1
debug2: host key algorithms: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: MACs ctos: 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
debug2: MACs stoc: 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
debug2: compression ctos: none,zlib@openssh.com
debug2: compression stoc: none,zlib@openssh.com
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
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:HbW3g8zUjNSksFbqTiUWPWg2Bq1x8xdGUrliXFzSnUw
debug1: Host 'gitlab.com' is known and matches the ECDSA host key.
debug1: Found key in /home/dev/.ssh/known_hosts:1
debug2: set_newkeys: mode 1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey after 134217728 blocks
debug2: key: /home/dev/.ssh/id_rsa (0x5577f463ab70)
debug2: key: /home/dev/.ssh/id_dsa ((nil))
debug2: key: /home/dev/.ssh/id_ecdsa ((nil))
debug2: key: /home/dev/.ssh/id_ed25519 ((nil))
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/dev/.ssh/id_rsa
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg rsa-sha2-512 blen 535
debug2: input_userauth_pk_ok: fp SHA256:8C08a2guSkrqmDI3TCqTFHCoEIYVwElKA5tC01Z11+w
debug1: Authentication succeeded (publickey).
Authenticated to gitlab.com ([35.231.145.151]:22).
debug2: fd 4 setting O_NONBLOCK
debug2: fd 5 setting O_NONBLOCK
debug1: channel 0: new [client-session]
debug2: channel 0: send open
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: Remote: Forced command.
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: PTY allocation disabled.
debug1: Remote: Forced command.
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: PTY allocation disabled.
debug2: callback start
debug2: fd 3 setting TCP_NODELAY
debug2: client_session2_setup: id 0
debug1: Sending environment.
debug1: Sending command: git-upload-pack 'org/node-modules/my-project.git'
debug2: channel 0: request exec confirm 1
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0
remote: Enumerating objects: 121, done.
remote: Counting objects: 100% (121/121), done.
remote: Compressing objects:  19% (11/56)

更新5

关闭iptables没有帮助:( sudo iptables -S -P INPUT ACCEPT -P FORWARD DROP -P OUTPUT ACCEPT -N DOCKER -N DOCKER-ISOLATION-STAGE-1 -N DOCKER-ISOLATION-STAGE-2 -N DOCKER-USER -A FORWARD -j DOCKER-USER -A FORWARD -j DOCKER-ISOLATION-STAGE-1 -A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT -A FORWARD -o docker0 -j DOCKER -A FORWARD -i docker0 ! -o docker0 -j ACCEPT -A FORWARD -i docker0 -o docker0 -j ACCEPT -A FORWARD -o br-050722b03652 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT -A FORWARD -o br-050722b03652 -j DOCKER -A FORWARD -i br-050722b03652 ! -o br-050722b03652 -j ACCEPT -A FORWARD -i br-050722b03652 -o br-050722b03652 -j ACCEPT -A DOCKER-ISOLATION-STAGE-1 -i docker0 ! -o docker0 -j DOCKER-ISOLATION-STAGE-2 -A DOCKER-ISOLATION-STAGE-1 -i br-050722b03652 ! -o br-050722b03652 -j DOCKER-ISOLATION-STAGE-2 -A DOCKER-ISOLATION-STAGE-1 -j RETURN -A DOCKER-ISOLATION-STAGE-2 -o docker0 -j DROP -A DOCKER-ISOLATION-STAGE-2 -o br-050722b03652 -j DROP -A DOCKER-ISOLATION-STAGE-2 -j RETURN -A DOCKER-USER -j RETURN

但是使用17525 /usr/bin/dockerd -H fd:// --iptables=false运行容器确实有帮助!是iptables问题吗?

1 个答案:

答案 0 :(得分:0)

原因是MTU参数。

docker0   Link encap:Ethernet  HWaddr 02:42:f8:a4:15:a3  
          inet addr:172.17.0.1  Bcast:172.17.255.255  Mask:255.255.0.0
          inet6 addr: fe80::42:f8ff:fea4:15a3/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:829041 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1171072 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:153118823 (153.1 MB)  TX bytes:989096966 (989.0 MB)

ens3      Link encap:Ethernet  HWaddr fa:16:3e:a9:5f:90  
          inet addr:192.168.6.206  Bcast:192.168.6.255  Mask:255.255.255.0
          inet6 addr: fe80::f816:3eff:fea9:5f90/64 Scope:Link
          inet6 addr: fd00::f816:3eff:fea9:5f90/64 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1450  Metric:1
          RX packets:514305724 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2916744 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:218188923564 (218.1 GB)  TX bytes:1728298553 (1.7 GB)

docker0的{​​{1}}比MTU大。

将配置放入ens3

/etc/docker/daemon

重新加载Docker守护程序: { "mtu": 1450 }