Mit dem Modul telnetlib.
import telnetlib
host = '192.168.0.10'
port = 23
timeout = 10
tn = telnetlib.Telnet(host, port, timeout)
command = b'enable\n'
tn.write(command)
received_data = tn.read_until(b'prompt> ')
print(received_data.decode('utf-8'))
tn.close()