0

I am running this:

ssh_command = f'ssh -vvv -o StrictHostKeyChecking=no -i {private_key_file} ubuntu@{public_ip}'

# Use os.system to execute the SSH command in a subshell
os.system(ssh_command)

However, this only works 40% of the time. All of the debugging I have seen would either work or not work 100% of the time. My connectivity is not shaky as far as I can tell. I am ssh'ing into an EC2.

I often get this error:

OpenSSH_9.4p1, LibreSSL 3.3.6
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files
debug1: /etc/ssh/ssh_config line 54: Applying options for *
debug2: resolve_canonicalize: hostname [...] is address
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/Users/scott/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/Users/scott/.ssh/known_hosts2'
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug3: ssh_connect_direct: entering
debug1: Connecting to [...] [[...]] port 22.
debug3: set_sock_tos: set socket 3 IP_TOS 0x48
debug1: connect to address [...] port 22: Connection refused
ssh: connect to host [...] port 22: Connection refused

I am on MacOS 14.2.1 but ssh'ing into an Ubuntu server. When I ssh manually, I have no issues.

3
  • I wonder if this is related? it appears to have the same error signature (in particular, the message about IP_TOS 0x48) Unable to connect to anything using ssh Commented Jan 20 at 20:46
  • You don't seem to be on Ubuntu or are using a non-standard SSH. Ubuntu 23.10 has SSH 9.3p1 with OpenSSL 3.0.10, not 9.4 with LibreSSL.
    – zwets
    Commented Jan 20 at 21:31
  • @zwets Thanks--this may be worth looking into. I am ssh'ing into Ubuntu. My computer is MacOS 14.2.1 (23C71).
    – BigMistake
    Commented Jan 21 at 1:04

0

You must log in to answer this question.

Browse other questions tagged .