Example #1
0
    def test_known_hosts_sshkeys(self):
        """Test connecting with known hosts passed in as SSHKeys"""

        keylist = asyncssh.read_public_key_list('skey.pub')

        with (yield from self.connect(known_hosts=(keylist, [], []))) as conn:
            pass

        yield from conn.wait_closed()
    def begin_auth(self, username):
        try:
            self._keys = \
                asyncssh.read_public_key_list('authorized_keys/%s.pub' %
                                                  username)
        except IOError:
            self._keys = []

        return True
Example #3
0
    def test_known_hosts_sshkeys(self):
        """Test connecting with known hosts passed in as SSHKeys"""

        keylist = asyncssh.read_public_key_list('skey.pub')

        with (yield from self.connect(known_hosts=(keylist, [], []))) as conn:
            pass

        yield from conn.wait_closed()
Example #4
0
    def check_public(self):
        """Check for a public key match"""

        newkey = read_public_key('new')
        self.assertEqual(newkey, self.pubkey)
        self.assertEqual(hash(newkey), hash(self.pubkey))

        run('cat new new > list')
        keylist = read_public_key_list('list')
        self.assertEqual(keylist[0], newkey)
        self.assertEqual(keylist[1], newkey)
Example #5
0
    def check_public(self):
        """Check for a public key match"""

        newkey = read_public_key('new')
        self.assertEqual(newkey, self.pubkey)
        self.assertEqual(hash(newkey), hash(self.pubkey))

        run('cat new new > list')
        keylist = read_public_key_list('list')
        self.assertEqual(keylist[0], newkey)
        self.assertEqual(keylist[1], newkey)
Example #6
0
    def __call__(self):
        database = Service.resolve("moxie.cores.database.DatabaseService")
        # self.alert = CronService.resolve("moxie.cores.alert.AlertService")
        # register an ssh callback for each thinger
        ssh_host_keys = asyncssh.read_private_key_list('ssh_host_keys')

        if MoxieSSHServer._keys is None:
            authorized_keys = {}
            for key in asyncssh.read_public_key_list('authorized_keys'):
                authorized_keys[key] = (yield from
                                        database.user.get_by_fingerprint(
                                            fingerprint(key)))

            MoxieSSHServer._keys = authorized_keys

        obj = yield from asyncssh.create_server(MoxieSSHServer,
                                                '0.0.0.0',
                                                2222,
                                                server_host_keys=ssh_host_keys)

        return obj
Example #7
0
File: ssh.py Project: dmc2015/moxie
    def __call__(self):
        database = Service.resolve("moxie.cores.database.DatabaseService")
        # self.alert = CronService.resolve("moxie.cores.alert.AlertService")
        # register an ssh callback for each thinger
        ssh_host_keys = asyncssh.read_private_key_list('ssh_host_keys')

        if MoxieSSHServer._keys is None:
            authorized_keys = {}
            for key in asyncssh.read_public_key_list('authorized_keys'):
                authorized_keys[key] = (yield from
                                        database.user.get_by_fingerprint(
                                            fingerprint(key)))

            MoxieSSHServer._keys = authorized_keys

        obj = yield from asyncssh.create_server(
            MoxieSSHServer, '0.0.0.0', 2222,
            server_host_keys=ssh_host_keys
        )

        return obj