打包程序在尝试建立 SSH 连接时循环访问端口



当Packer到达"等待SSH可用..."步。

我的日志显示

14:07:29 [INFO] Attempting SSH connection...
14:07:29 reconnecting to TCP connection for SSH
14:07:29 handshaking with SSH
14:07:29 handshake error: ssh: handshake failed: read tcp 127.0.0.1:60372->127.0.0.1:3057: read: connection reset by peer
14:07:29 [DEBUG] SSH handshake err: ssh: handshake failed: read tcp 127.0.0.1:60372->127.0.0.1:3057: read: connection reset by peer
14:07:36 [INFO] Attempting SSH connection...
14:07:36 reconnecting to TCP connection for SSH
14:07:36 handshaking with SSH
14:07:36 handshake error: ssh: handshake failed: read tcp 127.0.0.1:60376->127.0.0.1:3057: read: connection reset by peer
14:07:36 [DEBUG] SSH handshake err: ssh: handshake failed: read tcp 127.0.0.1:60376->127.0.0.1:3057: read: connection reset by peer

请注意每次尝试时的不同端口。

60372
60376

Packer正在尝试一个新端口,每7秒一次。

有没有办法在构建之前或期间配置端口以避免这种尝试/失败方法?

这是建立 ssh 连接的源端口。它由操作系统分配一个随机可用的高端口。

问题不在于SSH服务器或TCP/IP。这与Packer的设计方式有关。

创建 VM 后,Packer.io 将运行启动命令。这需要时间,并且时间因机器而异。在此期间,您将看到"等待 SSH 可用..."。在后台,Packer.io 将尝试建立 SSH 连接。日志中充斥着这样的消息

Linux
14:07:29 [INFO] Attempting SSH connection...
14:07:29 reconnecting to TCP connection for SSH
14:07:29 handshaking with SSH
14:07:29 handshake error: ssh: handshake failed: read tcp 127.0.0.1:60372->127.0.0.1:3057: read: connection reset by peer
14:07:29 [DEBUG] SSH handshake err: ssh: handshake failed: read tcp    127.0.0.1:60372->127.0.0.1:3057: read: connection reset by peer

Windows
15:54:31 packer.exe: 2017/02/01 15:54:31 [INFO] Attempting SSH connection...
15:54:31 packer.exe: 2017/02/01 15:54:31 reconnecting to TCP connection for SSH
15:54:31 packer.exe: 2017/02/01 15:54:31 handshaking with SSH
15:54:31 packer.exe: 2017/02/01 15:54:31 handshake error: ssh: handshake failed: read tcp 127.0.0.1:62691->127.0.0.1:4289: wsarecv: An existing connection was forcibly closed by the remote host.
15:54:31 packer.exe: 2017/02/01 15:54:31 [DEBUG] SSH handshake err: ssh: handshake failed: read tcp 127.0.0.1:62691->127.0.0.1:4289: wsarecv: An existing connection was forcibly closed by the remote host.

操作系统将启动,并且来宾上的SSH服务器将变为可用。届时,应建立从主机到来宾的SSH连接。

在 Windows 10 Pro 和 Ubuntu 16.04.1 TLS 上复制并确认

最新更新