I am able to sftp into both SERVER1 and SERVER2 (specified above). I can use the command line to sftp into both SERVER1 and SERVER2, no problem.
However, when I attempt to use python 3.7 (pysftp) to connect to SERVER2 I get back
DEBUG:paramiko.transport:Attempting password auth...
DEBUG:paramiko.transport:userauth is OK
DEBUG:paramiko.transport:Authentication type (password) not permitted.
DEBUG:paramiko.transport:Allowed methods: ['publickey', 'keyboard-interactive']
DEBUG:paramiko.transport:userauth is OK
INFO:paramiko.transport:Authentication (keyboard-interactive) failed.
Rather than run an extract using the command line, and some ETL processes in python, I would like to keep everything in one program - preferably python 3.7 and not use any public/private keys.
Any tips to have paramiko/pysftp initiate the keyboard-interactive?
import pysftp
import getpass
question = input ("Do you want to: A) Connect to SERVER1 B) Connect to SERVER2. [A/B]? : ")
# Decide whether SERVER 1 or SERVER 2
if question == "A":
hostname="SERVER1"
username='TESTUSER'
elif question == "B": # STILL CANNOT FIGURE OUT HOW TO PROPERLY CONNECT TO SIS SFTP
hostname="SERVER2"
username='###USER'
else:
print("Not permitted")
# Get security clearances, don't want to hardcode any passwords right now
tkpass = getpass.getpass("Password:")
# DEBUGGER HERE
import sys
import logging
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
# Make the connection to the server
srv = pysftp.Connection(host=hostname, username=username,
password=tkpass)
# Get the directory and file listing
data = srv.listdir()
# Closes the connection
srv.close()
# Prints out the directories and files, line by line
for i in data:
print(i)