Exemplo n.º 1
0
 def test_getHostKeyAlgorithms(self):
     """
     For a given host, get the host key algorithms for that
     host in the known_hosts file.
     """
     hostsFile = self.loadSampleHostsFile()
     hostsFile.addHostKey(b"www.twistedmatrix.com",
                          Key.fromString(otherSampleKey))
     hostsFile.addHostKey(b"www.twistedmatrix.com",
                          Key.fromString(ecdsaSampleKey))
     hostsFile.save()
     options = {}
     options['known-hosts'] = hostsFile.savePath.path
     algorithms = default.getHostKeyAlgorithms(b"www.twistedmatrix.com",
                                               options)
     expectedAlgorithms = [b'ssh-rsa', b'ecdsa-sha2-nistp256']
     self.assertEqual(algorithms, expectedAlgorithms)
Exemplo n.º 2
0
 def test_getHostKeyAlgorithms(self):
     """
     For a given host, get the host key algorithms for that
     host in the known_hosts file.
     """
     hostsFile = self.loadSampleHostsFile()
     hostsFile.addHostKey(
         b"www.twistedmatrix.com", Key.fromString(otherSampleKey))
     hostsFile.addHostKey(
         b"www.twistedmatrix.com", Key.fromString(ecdsaSampleKey))
     hostsFile.save()
     options = {}
     options['known-hosts'] = hostsFile.savePath.path
     algorithms = default.getHostKeyAlgorithms(
                      b"www.twistedmatrix.com", options)
     expectedAlgorithms = [b'ssh-rsa', b'ecdsa-sha2-nistp256']
     self.assertEqual(algorithms, expectedAlgorithms)
Exemplo n.º 3
0
def doConnect():
    if "@" in options["host"]:
        options["user"], options["host"] = options["host"].split("@", 1)
    if not options.identitys:
        options.identitys = ["~/.ssh/id_rsa", "~/.ssh/id_dsa"]
    host = options["host"]
    if not options["user"]:
        options["user"] = getpass.getuser()
    if not options["port"]:
        options["port"] = 22
    else:
        options["port"] = int(options["port"])
    host = options["host"]
    port = options["port"]
    vhk = default.verifyHostKey
    if not options["host-key-algorithms"]:
        options["host-key-algorithms"] = default.getHostKeyAlgorithms(
            host, options)
    uao = default.SSHUserAuthClient(options["user"], options, SSHConnection())
    connect.connect(host, port, options, vhk, uao).addErrback(_ebExit)
Exemplo n.º 4
0
def doConnect():
    if '@' in options['host']:
        options['user'], options['host'] = options['host'].split('@', 1)
    if not options.identitys:
        options.identitys = ['~/.ssh/id_rsa', '~/.ssh/id_dsa']
    host = options['host']
    if not options['user']:
        options['user'] = getpass.getuser()
    if not options['port']:
        options['port'] = 22
    else:
        options['port'] = int(options['port'])
    host = options['host']
    port = options['port']
    vhk = default.verifyHostKey
    if not options['host-key-algorithms']:
        options['host-key-algorithms'] = default.getHostKeyAlgorithms(
            host, options)
    uao = default.SSHUserAuthClient(options['user'], options, SSHConnection())
    connect.connect(host, port, options, vhk, uao).addErrback(_ebExit)
Exemplo n.º 5
0
def doConnect():
#    log.deferr = handleError # HACK
    if '@' in options['host']:
        options['user'], options['host'] = options['host'].split('@',1)
    if not options.identitys:
        options.identitys = ['~/.ssh/id_rsa', '~/.ssh/id_dsa']
    host = options['host']
    if not options['user']:
        options['user'] = getpass.getuser()
    if not options['port']:
        options['port'] = 22
    else:
        options['port'] = int(options['port'])
    host = options['host']
    port = options['port']
    vhk = default.verifyHostKey
    if not options['host-key-algorithms']:
        options['host-key-algorithms'] = default.getHostKeyAlgorithms(
                                             host, options)
    uao = default.SSHUserAuthClient(options['user'], options, SSHConnection())
    connect.connect(host, port, options, vhk, uao).addErrback(_ebExit)