securecrt python脚本用特殊端口打开ssh

时间:2017-12-18 09:01:14

标签: python ssh port

如何使用python脚本创建带有特殊ssh端口的选项卡, 像这样:

# $language = "python"
# $interface = "1.0"
host = '192.168.1.1'
user = 'test'
passwd = 'test'

def main():
    # how to use the port 22333 for ssh
    cmd = "/SSH2 /PASSWORD %s %s@%s port=22567" % (passwd, user, host)
    crt.Session.ConnectInTab(cmd, True)

main()

这不起作用,但使用默认端口22,它正在工作:

cmd = "/SSH2 /PASSWORD %s %s@%s" % (passwd, user, host)

感谢

1 个答案:

答案 0 :(得分:2)

按如下方式更新cmd:

cmd = "/SSH2 /PASSWORD %s %s@%s /P 22567" % (passwd, user, host)

cmd = "/SSH2 /PASSWORD %s %s@%s -p 22567" % (passwd, user, host)

参考:http://theory.uchicago.edu/~smaria/adam_ssh/SSH%20Secure%20Shell/documentation/SSH2.html