示例#1
0
 def setOption(self, option, value):
     if (option == SSH_OPTIONS_PORT_STR or option == SSH_OPTIONS_USER
         or option == SSH_OPTIONS_USER or option == SSH_OPTIONS_SSH_DIR
         or option == SSH_OPTIONS_IDENTITY or option == SSH_OPTIONS_ADD_IDENTITY
         or option == SSH_OPTIONS_KNOWNHOSTS or option == SSH_OPTIONS_LOG_VERBOSITY_STR
         or option == SSH_OPTIONS_CIPHERS_C_S or option == SSH_OPTIONS_CIPHERS_S_C
         or option == SSH_OPTIONS_COMPRESSION_C_S or option == SSH_OPTIONS_COMPRESSION_S_C
         or option == SSH_OPTIONS_PROXYCOMMAND or option == SSH_OPTIONS_BINDADDR
         or option == SSH_OPTIONS_HOST):
         rc = lib.ssh_options_set(self.session, option, cstring(value))
         self.check(rc)
         return rc
     raise RuntimeError("Unhandled option " + str(option))
示例#2
0
    def __init__(self, hostname=None, port=None, username=None):
        self.session = lib.ssh_new()

        if hostname:
            lib.ssh_options_set(self.session, SSH_OPTIONS_HOST, cstring(hostname))
            
        if username:
            lib.ssh_options_set(self.session, SSH_OPTIONS_USER, cstring(username))

        lib.ssh_options_set(self.session, SSH_OPTIONS_PORT_STR, cstring(port))