def authenticator(self, sock): channel = rpyc.Channel(rpyc.SocketStream(sock)) password = channel.recv().decode('utf-8') if password != self.password: channel.send(AUTH_ERROR) raise rpyc.utils.authenticators.AuthenticationError('Invalid password from client.') channel.send(AUTH_SUCCESS) return sock, self.password
def client_authenticator(sock): channel = rpyc.Channel(rpyc.SocketStream(sock)) data = channel.recv() data = rpyc.core.brine.load(data) login = data[0] password = data[1] config_parser = ConfigFileParser.ConfigFileParser() expected_login = config_parser.login() expected_password = config_parser.password() if login != expected_login or password != expected_password: channel.send('AUTH_ERROR') raise rpyc.utils.authenticators.AuthenticationError( 'Invalid password from client.') channel.send('AUTH_SUCCESS') return sock, None
import rpyc from plumbum.paramiko_machine import ParamikoMachine mach = ParamikoMachine("192.168.1.143") sock = mach.connect_sock(18812) conn = rpyc.classic.connect_stream(rpyc.SocketStream(sock)) print conn.modules.sys print conn.modules.sys.platform #mach.close() #conn.close()