Packer loops through ports when attempting to establish SSH connection - ssh

When Packer reaches the "Waiting for SSH to become available..." step.
My logs show
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
Note a different port on each attempt.
60372
60376
Packer is trying a new port, every 7 seconds.
Is there a way to configure the ports before or during the build to avoid this try/fail approach?

That is the source port which the ssh connection is made from. It's assigned by the OS with a random available high port.

The issue is not with SSH Server or TCP/IP. It is with the way Packer is designed.
When a VM is created, Packer.io will run boot commands. It takes time and time varies on different machines. During that time you will see "Waiting for SSH to become available...". On the background, Packer.io will be attempting to establish an SSH connection. The log is saturated with messages like this
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
or
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.
OS will boot and with it SSH server on the guest will become available. At that moment SSH connection from host to guest should establish.
Reproduced and Confirmed on Windows 10 Pro and Ubuntu 16.04.1 TLs

Related

NMSSH: Socket connection successful but then fail to establishing SSH session

I was able to SSH into my IoT device yesterday, but this morning when I try to connect it again. it fails to establish SSH session.
2021-08-25 09:25:53.501096-0400 [1387:464804] NMSSH: Socket connection to 192.168.77.30 on port 22 succesful
2021-08-25 09:25:53.551438-0400 [1387:464804] NMSSH: Failure establishing SSH session
It seems like socket connection success and then fails.
Any help is appreciated.

Failed to connect to s3.amazonaws.com port 443: Connexion refused

I have a problem with amazon S3, I created a site hosted on OVH, when I am on the site I can upload and download files but when I try to connect in SSH, I have the following error:
running : curl -v https://s3.amazonaws.com
* Rebuilt URL to: https://s3.amazonaws.com/
* Hostname was NOT found in DNS cache
* Trying 52.216.241.214...
* connect to 52.216.241.214 port 443 failed: Connexion refused
* Failed to connect to s3.amazonaws.com port 443: Connexion refused
* Closing connection 0
curl: (7) Failed to connect to s3.amazonaws.com port 443: Connexion refused
If someone has an idea where the problem may come from and how to resolve it, it would really help me

Can not download anything from https://mitmproxy.org/downloads/#4.0.4/

Can't download anything from here
I've tried to download the file several times from different Linux machines:
wget --no-check-certificate --secure-protocol=TLSv1 https://snapshots.mitmproxy.org/4.0.4/mitmproxy-4.0.4-windows-installer.exe
--2019-12-19 16:26:46-- https://snapshots.mitmproxy.org/4.0.4/mitmproxy-4.0.4-windows-installer.exe
Resolving snapshots.mitmproxy.org... 143.204.101.60, 143.204.101.113, 143.204.101.39, ...
Connecting to snapshots.mitmproxy.org|143.204.101.60|:443... connected.
OpenSSL: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure
Unable to establish SSL connection.
wget --no-check-certificate --secure-protocol=TLSv1 https://snapshots.mitmproxy.org/4.0.4/mitmproxy-4.0.4-windows-installer.exe.
--2019-12-19 15:27:51-- https://snapshots.mitmproxy.org/4.0.4/mitmproxy-4.0.4-windows-installer.exe.
Resolving snapshots.mitmproxy.org (snapshots.mitmproxy.org)... 13.32.43.97, 13.32.43.82, 13.32.43.47, ...
Connecting to snapshots.mitmproxy.org (snapshots.mitmproxy.org)|13.32.43.97|:443... connected.
GnuTLS: Error in the pull function.
Unable to establish SSL connection.
curl -L0 https://snapshots.mitmproxy.org/4.0.4/mitmproxy-4.0.4-windows-installer.exe
curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to snapshots.mitmproxy.org:443
And finally, FireFox says PR_CONNECT_RESET_ERROR.
Any way to help me to download the mentioned file ?

Mosquitto over SSL refuses publishing message

I am having some trouble with Mosquitto (MQTT) over SSL (with letsencrypt).
I have it installed on a RoR Ubuntu 18.04 server, on Digital Ocean, with Nginx installed.
This setup worked perfectly for public messages.
Then, for communication over SSL, port 8883 is listening to all traffic on the domain name.
The ports are allowed in firewall.
My Problem is, whenever I try to publish over SSL, I get an error. Here's the full log:
$mosquitto_pub -d -h my-domain.xyz -t test -m "hello again" -p 8883 --capath /etc/ssl/certs/ -u “some-user” -P "p#s$w0rd"
Client mosqpub|23889-mosquitto sending CONNECT
Client mosqpub|23889-mosquitto received CONNACK
Connection Refused: not authorised.
Error: The connection was refused.
Here is my ../conf.d/default.conf
allow_anonymous false
password_file /etc/mosquitto/passwd
​
listener 1883 localhost
​
listener 8883
certfile /etc/letsencrypt/live/my-domain.xyz/cert.pem
cafile /etc/letsencrypt/live/my-domain.xyz/chain.pem
keyfile /etc/letsencrypt/live/my-domain.xyz/privkey.pem
Sample password file from /etc/mosquitto/passwd:
some-user:$6$SzAZtOMrxYGiECMU$1YMk4lnmY8FRTZj/vy1FLsnegsxx4OXSzX60rX7ej+muz1i6//16BKwkvwXYYYg2+7w9SRYaeuKPfA9Q==
Command to subscribe
mosquitto_sub -h domain.xyz -t "test" -u "some-user" -P "p#s$w0rd"
Log as found in /var/log/mosquitto/mosquitto.og
1568255494: Opening ipv4 listen socket on port 8883.
1568255664: mosquitto version 1.4.15 terminating
1568523128: mosquitto version 1.4.15 (build date Tue, 18 Jun 2019 11:42:22 -0300) starting
1568523397: mosquitto version 1.4.15 (build date Tue, 18 Jun 2019 11:42:22 -0300) starting
1568523397: Config loaded from /etc/mosquitto/mosquitto.conf.
1568523397: Opening ipv4 listen socket on port 1883.
1568523397: Error: Address already in use
1568523128: Config loaded from /etc/mosquitto/mosquitto.conf.
1568523128: Opening ipv4 listen socket on port 8883.
1568523397: mosquitto version 1.4.15 terminating
When I run mosquitto client in blocking mode by manually providing the conf file, here's what I get:
$ mosquitto -c /etc/mosquitto/conf.d/default.conf
1568594709: mosquitto version 1.4.15 (build date Tue, 18 Jun 2019 11:42:22 -0300) starting
1568594709: Config loaded from /etc/mosquitto/conf.d/default.conf.
1568594709: Opening ipv4 listen socket on port 1883.
1568594709: Opening ipv4 listen socket on port 8883.
1568594709: Opening ipv6 listen socket on port 8883.
1568594709: Error: Unable to load CA certificates. Check cafile "/etc/letsencrypt/live/my-domain.xyz/chain.pem".
Does it look like a permissions problem?
I followed the following guide, on an Ubuntu 18.04 : https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-the-mosquitto-mqtt-messaging-broker-on-ubuntu-16-04
What could be going wrong?
I can provide any other details that you want.

Bluemix / Liberty / Eclipse - Console proxy: error connecting to IP

Eclipse Neon with Bluemix Liberty Plugin and WLP tools installed is throwing the following error at the Eclipse console (every 5 seconds):
proxy: error connecting to 75.126.XXX.XX:8081: dial tcp 75.126.XXX.XX:8081: i/o timeout
proxy: error connecting to 75.126.XXX.XX:8081: dial tcp 75.126.XXX.XX:8081: i/o timeout
proxy: error connecting to 75.126.XXX.XX:8081: dial tcp 75.126.XXX.XX:8081: i/o timeout
proxy: error connecting to 75.126.XXX.XX:8081: dial tcp 75.126.XXX.XX:8081: i/o timeout
proxy: error connecting to 75.126.XXX.XX:8081: dial tcp 75.126.XXX.XX:8081: i/o timeout
proxy: error connecting to 75.126.XXX.XX:8081: dial tcp 75.126.XXX.XX:8081: i/o timeout
proxy: error connecting to 75.126.XXX.XX:8081: dial tcp 75.126.XXX.XX:8081: i/o timeout
proxy: error connecting to 75.126.XXX.XX:8081: dial tcp 75.126.XXX.XX:8081: i/o timeout
Note: The log doesn't actually show X's in the IP, the full IP has been hidden.
The error started right after adding and removing a second WLP server instance using the WebSphere Liberty Tool plugin. Is it possible to fix it at the configuration side?
This was a temporary issue with the loggregator service. It should be working fine now.