1
votes

This is my first time using paramiko. I'm trying to establish an SSH session to a test Amazon Linux 2 instance where I've enabled password authentication, since that doesn't come enabled by default and restarted the SSH daemon on the box. I also made sure that I could connect with SSH via the normal SSH program using the username / password I put in the Python program.

When I run the Python code below, everything looks good and it waits for input and keeps the program running, but when I'm logged into the Amazon instance, I don't see the paramiko user logged in (I did a "w" and a "who" command). In fact, I have no evidence server-side that Paramiko ever connects successfully to begin with.

#!/usr/bin/env python3

import pprint
import boto3
import os
import paramiko

os.system('clear')

pp = pprint.PrettyPrinter(indent=4)

client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

client.connect('X.X.X.X',username='the_username',password='the_password',port=22)

get_input = input("Preventing program from closing and keeping SSH connectiion alive...")
1

1 Answers

0
votes

who shows interactive shell sessions only.

Your code only connects. It does not start a shell, let only an interactive shell.

See List all connected SSH sessions?