当我运行vagrant up
时,尝试使用insecure_private_key连接到VM时,我的设置会挂起。它不断尝试和尝试与此类似的输出:
INFO retryable: Retryable exception raised: #<Errno::ECONNRESET: Connection reset by peer>
INFO ssh: Attempting to connect to SSH...
INFO ssh: - Host: 192.168.121.80
INFO ssh: - Port: 22
INFO ssh: - Username: vagrant
INFO ssh: - Password? false
INFO ssh: - Key Path: ["/home/users/swalter/.vagrant.d/insecure_private_key"]
DEBUG ssh: == Net-SSH connection debug-level log START ==
DEBUG ssh: D, [2015-10-13T15:04:11.236064 #24396] DEBUG -- net.ssh.transport.session[3fa468444c28]: establishing connection to 192.168.121.80:22
D, [2015-10-13T15:04:11.236454 #24396] DEBUG -- net.ssh.transport.session[3fa468444c28]: connection established
I, [2015-10-13T15:04:11.236614 #24396] INFO -- net.ssh.transport.server_version[3fa468444264]: negotiating protocol version
D, [2015-10-13T15:04:11.262088 #24396] DEBUG -- net.ssh.transport.server_version[3fa468444264]: remote is `SSH-2.0-OpenSSH_5.3'
D, [2015-10-13T15:04:11.262176 #24396] DEBUG -- net.ssh.transport.server_version[3fa468444264]: local is `SSH-2.0-Ruby/Net::SSH_2.9.1 x86_64-linux'
D, [2015-10-13T15:04:11.263494 #24396] DEBUG -- tcpsocket[3fa468444868]: read 840 bytes
D, [2015-10-13T15:04:11.263615 #24396] DEBUG -- tcpsocket[3fa468444868]: received packet nr 0 type 20 len 836
I, [2015-10-13T15:04:11.263706 #24396] INFO -- net.ssh.transport.algorithms[3fa4683ed9c8]: got KEXINIT from server
I, [2015-10-13T15:04:11.263819 #24396] INFO -- net.ssh.transport.algorithms[3fa4683ed9c8]: sending KEXINIT
D, [2015-10-13T15:04:11.264016 #24396] DEBUG -- tcpsocket[3fa468444868]: queueing packet nr 0 type 20 len 2020
D, [2015-10-13T15:04:11.264098 #24396] DEBUG -- tcpsocket[3fa468444868]: sent 2024 bytes
I, [2015-10-13T15:04:11.264130 #24396] INFO -- net.ssh.transport.algorithms[3fa4683ed9c8]: negotiating algorithms
D, [2015-10-13T15:04:11.264253 #24396] DEBUG -- net.ssh.transport.algorithms[3fa4683ed9c8]: negotiated:
* kex: diffie-hellman-group-exchange-sha1
* host_key: ssh-rsa
* encryption_server: aes128-cbc
* encryption_client: aes128-cbc
* hmac_client: hmac-sha1
* hmac_server: hmac-sha1
* compression_client: none
* compression_server: none
* language_client:
* language_server:
D, [2015-10-13T15:04:11.264283 #24396] DEBUG -- net.ssh.transport.algorithms[3fa4683ed9c8]: exchanging keys
D, [2015-10-13T15:04:11.264478 #24396] DEBUG -- tcpsocket[3fa468444868]: queueing packet nr 1 type 34 len 20
D, [2015-10-13T15:04:11.264533 #24396] DEBUG -- tcpsocket[3fa468444868]: sent 24 bytes
D, [2015-10-13T15:04:11.265762 #24396] DEBUG -- tcpsocket[3fa468444868]: read 152 bytes
D, [2015-10-13T15:04:11.265844 #24396] DEBUG -- tcpsocket[3fa468444868]: received packet nr 1 type 31 len 148
D, [2015-10-13T15:04:11.267446 #24396] DEBUG -- tcpsocket[3fa468444868]: queueing packet nr 2 type 32 len 140
D, [2015-10-13T15:04:11.267521 #24396] DEBUG -- tcpsocket[3fa468444868]: sent 144 bytes
D, [2015-10-13T15:04:11.269986 #24396] DEBUG -- tcpsocket[3fa468444868]: read 720 bytes
D, [2015-10-13T15:04:11.270066 #24396] DEBUG -- tcpsocket[3fa468444868]: received packet nr 2 type 33 len 700
D, [2015-10-13T15:04:11.271360 #24396] DEBUG -- tcpsocket[3fa468444868]: queueing packet nr 3 type 21 len 20
D, [2015-10-13T15:04:11.271432 #24396] DEBUG -- tcpsocket[3fa468444868]: sent 24 bytes
D, [2015-10-13T15:04:11.271491 #24396] DEBUG -- tcpsocket[3fa468444868]: received packet nr 3 type 21 len 12
D, [2015-10-13T15:04:11.271752 #24396] DEBUG -- net.ssh.authentication.session[3fa468414758]: beginning authentication of `vagrant'
D, [2015-10-13T15:04:11.271858 #24396] DEBUG -- tcpsocket[3fa468444868]: queueing packet nr 4 type 5 len 28
D, [2015-10-13T15:04:11.271905 #24396] DEBUG -- tcpsocket[3fa468444868]: sent 52 bytes
D, [2015-10-13T15:04:11.311362 #24396] DEBUG -- tcpsocket[3fa468444868]: read 52 bytes
D, [2015-10-13T15:04:11.311453 #24396] DEBUG -- tcpsocket[3fa468444868]: received packet nr 4 type 6 len 28
D, [2015-10-13T15:04:11.311547 #24396] DEBUG -- net.ssh.authentication.session[3fa468414758]: trying none
D, [2015-10-13T15:04:11.311650 #24396] DEBUG -- tcpsocket[3fa468444868]: queueing packet nr 5 type 50 len 44
D, [2015-10-13T15:04:11.311709 #24396] DEBUG -- tcpsocket[3fa468444868]: sent 68 bytes
D, [2015-10-13T15:04:11.312042 #24396] DEBUG -- tcpsocket[3fa468444868]: read 84 bytes
D, [2015-10-13T15:04:11.312109 #24396] DEBUG -- tcpsocket[3fa468444868]: received packet nr 5 type 51 len 60
D, [2015-10-13T15:04:11.312177 #24396] DEBUG -- net.ssh.authentication.session[3fa468414758]: allowed methods: publickey,gssapi-keyex,gssapi-with-mic,password
D, [2015-10-13T15:04:11.312226 #24396] DEBUG -- net.ssh.authentication.methods.none[3fa46845d0d4]: none failed
D, [2015-10-13T15:04:11.312276 #24396] DEBUG -- net.ssh.authentication.session[3fa468414758]: trying publickey
D, [2015-10-13T15:04:11.312520 #24396] DEBUG -- net.ssh.authentication.agent[3fa46846971c]: connecting to ssh-agent
D, [2015-10-13T15:04:11.312672 #24396] DEBUG -- net.ssh.authentication.agent[3fa46846971c]: sending agent request 1 len 44
DEBUG ssh: == Net-SSH connection debug-level log END ==
如果我拿ip地址尝试ssh,打开一个新终端,ssh -i ~/.vagrant.d/insecure_private_key vagrant@192.168.121.80
它工作正常。
我如何能够ssh到实例而不是这个流浪的过程?
这是我的配置文件:
Vagrant.configure("2") do |config|
config.vm.box = "centos/6"
config.ssh.insert_key = false
# Controller node
config.vm.define "vbit00" do |n|
n.vm.network "private_network", ip: "192.168.122.10", netmask: "255.255.255.0"
n.vm.provider :libvirt do |libvirt|
libvirt.driver = "kvm"
libvirt.connect_via_ssh = false
libvirt.username = "root"
libvirt.storage_pool_name = "default"
libvirt.memory = 2048
end
end
# Storage nodes
config.vm.define "vbit06" do |n|
n.vm.network "private_network", ip: "192.168.122.20", netmask: "255.255.255.0"
n.vm.network "private_network", ip: "192.168.123.20", netmask: "255.255.255.0"
n.vm.provider :libvirt do |libvirt|
libvirt.driver = "kvm"
libvirt.connect_via_ssh = false
libvirt.username = "root"
libvirt.storage_pool_name = "default"
libvirt.storage :file, :size=> '11G'
libvirt.memory = 1024
end
end
config.vm.define "vbit07" do |n|
n.vm.network "private_network", ip: "192.168.122.21", netmask: "255.255.255.0"
n.vm.network "private_network", ip: "192.168.123.21", netmask: "255.255.255.0"
n.vm.provider :libvirt do |libvirt|
libvirt.driver = "kvm"
libvirt.connect_via_ssh = false
libvirt.username = "root"
libvirt.storage_pool_name = "default"
libvirt.storage :file, :size=> '11G'
libvirt.memory = 1024
end
end
# Compute nodes
config.vm.define "vbit10" do |n|
n.vm.network "private_network", ip: "192.168.122.30", netmask: "255.255.255.0"
n.vm.network "private_network", ip: "192.168.123.30", netmask: "255.255.255.0"
n.vm.provider :libvirt do |libvirt|
libvirt.driver = "kvm"
libvirt.connect_via_ssh = false
libvirt.username = "root"
libvirt.storage_pool_name = "default"
libvirt.storage :file, :size=>"5G"
libvirt.memory = 4096
end
end
config.vm.define "vbit11" do |n|
n.vm.network "private_network", ip: "192.168.122.31", netmask: "255.255.255.0"
n.vm.network "private_network", ip: "192.168.123.31", netmask: "255.255.255.0"
n.vm.provider :libvirt do |libvirt|
libvirt.driver = "kvm"
libvirt.connect_via_ssh = false
libvirt.username = "root"
libvirt.storage_pool_name = "default"
libvirt.storage :file, :size=>'5G'
libvirt.memory = 4096
end
end
end
答案 0 :(得分:0)
我明白了。无论流浪者为端口转发负责什么,本地主机的2222端口到远程主机22端口都不起作用。我用这样的ssh设置我自己的端口:ssh -L 2222:192.168.121.24:22 127.0.0.1
其中192.168.121.24是尝试引导的VM的IP地址。我知道IP地址,因为我正在看日志。然而,奇怪的是,在我销毁了该VM并重新创建它之后,它才起作用。我不需要使用新VM的IP地址重新创建端口转发。就像流浪汉看到它一次工作一样,它停止向前检查港口。
无论哪种方式,它现在都在工作,但只在我创建端口前进的终端中。我想可以使用iptables或firewalld完成更系统化的端口转发。