Click here to Skip to main content
15,742,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to create a simple python script to telnet into a lab switch. The problem is that by default when manually telnetting into the switch it attempts "automatic login" where you get the following:

User Access Verification

Username: Kerberos: No default realm defined for Kerberos!

To get around this problem when telnetting manually I have to specify a '-K' option on the command line. I'm wondering how this can be implemented as part of the telnetlib.

What I have tried:

My code:

import getpass
import telnetlib
HOST = ""
user = input("Enter your Username: ")
password = getpass.getpass()
enablepassword = getpass.getpass()
tn = telnetlib.Telnet(HOST)

tn.read_until(b"Username: ")

tn.write(user.encode('ascii') + b"\n")

#if password:
tn.read_until(b"Password: ")
tn.write(password.encode('ascii') + b"\n")

tn.write(b"sh ip int brie\n")


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900