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.
IP_TOS 0x48
) Unable to connect to anything using ssh