def test_get1(self): sredis = StorageRedis() pubkey = 'AAAAB3NzaC1yc2EAAAABIwAAAGEArzJx8OYOnJmzf4tfBEvLi8DVPrJ3/c9k2I/Az64fxjHf9imyRJbixtQhlH9lfNjUIx+4LmrJH5QNRsFporcHDKOTwTTYLh5KmRpslkYHRivcJSkbh/C+BR3utDS555mV' username = sredis.get_username(pubkey) self.assertEqual(username, "rauburtin") userinfo = sredis.get_userinfo(username) self.assertDictEqual(userinfo, {'remote': 'localhost', 'port': '22'})
def test_get1(self): sredis = StorageRedis() pubkey = "AAAAB3NzaC1yc2EAAAABIwAAAGEArzJx8OYOnJmzf4tfBEvLi8DVPrJ3/c9k2I/Az64fxjHf9imyRJbixtQhlH9lfNjUIx+4LmrJH5QNRsFporcHDKOTwTTYLh5KmRpslkYHRivcJSkbh/C+BR3utDS555mV" username = sredis.get_username(pubkey) self.assertEqual(username, "rauburtin") userinfo = sredis.get_userinfo(username) self.assertDictEqual(userinfo, {"remote": "localhost", "port": "22"})
def requestAvatarId(self, credentials): # check http://wiki.velannes.com/doku.php?id=python:programmes:twisted_ssh_server publickey = base64.b64encode(credentials.blob) log.msg("Client publickey:%s" % (publickey), logLevel=logging.DEBUG) log.msg("Client username %s" % (credentials.username), logLevel=logging.DEBUG) sredis = StorageRedis() username = sredis.get_username(publickey) log.msg("username from redis",username, logLevel=logging.DEBUG) if username == credentials.username: return defer.succeed(credentials.username) else: return defer.fail(error.UnauthorizedLogin( "invalid pubkey for username: %s" % (credentials.username)))
def requestAvatarId(self, credentials): # check http://wiki.velannes.com/doku.php?id=python:programmes:twisted_ssh_server publickey = base64.b64encode(credentials.blob) log.msg("Client publickey:%s" % (publickey), logLevel=logging.DEBUG) log.msg("Client username %s" % (credentials.username), logLevel=logging.DEBUG) sredis = StorageRedis() username = sredis.get_username(publickey) log.msg("username from redis", username, logLevel=logging.DEBUG) if username == credentials.username: return defer.succeed(credentials.username) else: return defer.fail( error.UnauthorizedLogin("invalid pubkey for username: %s" % (credentials.username)))
def __init__(self, username): avatar.ConchUser.__init__(self) self.username = username self.otherGroups = [] self.channelLookup.update({'session':session.SSHSession}) self.subsystemLookup['sftp'] = filetransfer.FileTransferServer #here we can create the client #need to pass the remote ssh server ip and port log.msg("Start SFTPServerProxyClient", logLevel=logging.DEBUG) sredis = StorageRedis() self.userinfo = sredis.get_userinfo(username) log.msg("userinfo from redis",self.userinfo, logLevel=logging.DEBUG) self.proxyclient = SFTPServerProxyClient( remote=self.userinfo['remote'], port=int(self.userinfo['port']), user=self.userinfo['user'])
def __init__(self, username): avatar.ConchUser.__init__(self) self.username = username self.otherGroups = [] self.channelLookup.update({'session': session.SSHSession}) self.subsystemLookup['sftp'] = filetransfer.FileTransferServer #here we can create the client #need to pass the remote ssh server ip and port log.msg("Start SFTPServerProxyClient", logLevel=logging.DEBUG) sredis = StorageRedis() self.userinfo = sredis.get_userinfo(username) log.msg("userinfo from redis", self.userinfo, logLevel=logging.DEBUG) self.proxyclient = SFTPServerProxyClient( remote=self.userinfo['remote'], port=int(self.userinfo['port']), user=self.userinfo['user'])
#!/usr/bin/env python from pysftpproxy.storageredis import StorageRedis sredis = StorageRedis() pubkey=open("/home/rauburtin/.ssh/id_rsa.pub","r").read() if pubkey.endswith("\n"): pubkey = pubkey[:-1] if len(pubkey.split())==3: pubkey = ' '.join(pubkey.split()[:-1]) if len(pubkey.split())==2: pubkey = pubkey.split()[1] username="******" sredis.add_username(pubkey,username) sredis.add_userinfo(username,"192.168.22.14","32772","root","/")
#!/usr/bin/env python from pysftpproxy.storageredis import StorageRedis sredis = StorageRedis() pubkey = open("/home/rauburtin/.ssh/id_rsa.pub", "r").read() if pubkey.endswith("\n"): pubkey = pubkey[:-1] if len(pubkey.split()) == 3: pubkey = ' '.join(pubkey.split()[:-1]) if len(pubkey.split()) == 2: pubkey = pubkey.split()[1] username = "******" sredis.add_username(pubkey, username) sredis.add_userinfo(username, "localhost", "22", "root", "/")
#!/usr/bin/env python from pysftpproxy.storageredis import StorageRedis sredis = StorageRedis() pubkey = open("/home/rauburtin/.ssh/id_rsa.pub", "r").read() if pubkey.endswith("\n"): pubkey = pubkey[:-1] if len(pubkey.split()) == 3: pubkey = ' '.join(pubkey.split()[:-1]) if len(pubkey.split()) == 2: pubkey = pubkey.split()[1] username = "******" sredis.add_username(pubkey, username) sredis.add_userinfo(username, "192.168.22.14", "32772", "root", "/")
#!/usr/bin/env python from pysftpproxy.storageredis import StorageRedis sredis = StorageRedis() pubkey=open("/home/rauburtin/.ssh/id_rsa.pub","r").read() if pubkey.endswith("\n"): pubkey = pubkey[:-1] if len(pubkey.split())==3: pubkey = ' '.join(pubkey.split()[:-1]) if len(pubkey.split())==2: pubkey = pubkey.split()[1] username="******" sredis.add_username(pubkey,username) sredis.add_userinfo(username,"localhost","22","root","/")