import getpass import telnetlib HOST = "192.168.0.101" user = input("Digite o seu usuario: ") password = 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"conf t\n") tn.write(b"int loopback 0\n") tn.write(b"ip address 1.1.1.1 255.255.255.255\n") tn.write(b"end\n") tn.write(b"exit\n") print(tn.read_all().decode('ascii'))