Replies: 1 comment
-
Try with the standard username/password authentication feature and see if that works for you. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello team,
I need to connect to Linux server that uses two way authentication per user
for example in putty when I ssh it will ask for username, then prompt for PIN once this provided, it will prompt for a password, once that provided the server will accept the handshake and create the connection.
Any idea how accomplish this with ssh2-Python?
so far my code is simple
`import socket
from ssh2.session import Session
from getpass import getpass
host = input("Enter Hostname :")
user = input("Enter Username :")
password = getpass("Enter Password :")
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((host, 22))
session = Session()
session.handshake(sock)
session.userauth_keyboardinteractive(user, password)
channel = session.open_session()
channel.execute('ls -l')
size, data = channel.read()
while size > 0:
print(data.decode())
size, data = channel.read()
channel.close()
print("Exit status: {0}".format(channel.get_exit_status()))`
currently the [session.userauth_keyboardinteractive(user, password)] line is getting ssh2.exceptions.AuthenticationError
Any help is appreciated
Beta Was this translation helpful? Give feedback.
All reactions