-1

I'm converting a VB script that connects to a switch through SecureCRT into Python3. The original script contains:

crt.Session.Connect " /SSH2 /L " & user & " /PASSWORD " & pass & " /P 22" & " /ACCEPTHOSTKEYS " & ip

This script runs this command and continues through the rest of code, automated as it should be.

In my version, I use the line:

crt.Session.Connect("SSH2/L %s /PASSWORD %s /P 22 /ACCEPTHOSTKEYS %s" % (user,pass,ip))

My script runs up until this point where CRT displays:

#Banner
Please enter login information for #ip.
Username:

And it hangs there. I can manually type in user and the script continues on as expected from that point. Interrupting the script shows that it is hanging on this line, presumably waiting for an input? How do I ensure the script sends the username as part of the command instead of requiring the user's input?

Shadomew
  • 109
  • 4

1 Answers1

0

Figured it out, and it's embarrassingly obvious. The line in python should be

crt.Session.Connect("/SSH2 /L %s /PASSWORD %s /P 22 /ACCEPTHOSTKEYS %s" % (user,pw,ip))

instead of

crt.Session.Connect("SSH2/L %s /PASSWORD %s /P 22 /ACCEPTHOSTKEYS %s" % (user,pw,ip))
Shadomew
  • 109
  • 4