1
Good afternoon, I am with a project that copies a file from a server and plays it in a directory mapped to collect information from the file , but when connecting and executing the command to copy , returns the following error ->
([], ['Permission denied, Please Try Again. r n', 'Permission denied, Please Try Again. r n', 'Permission denied (publickey,gssapi-keyex,gssapi-with-Mic,password). r n'])
I looked deeper on the internet and realized that this command needs a password , but I can not put this password , I tried the following code
stdin, stdout, stderr = ssh.ssh.exec_command("scp root@p1:/home/pos/log/arqEspelho /retaguarda/", get_pty=True)
stdin.write('xxxxxx' + '\n')
but does not return any error and no way for me to put the password , my code is like this , some suggestion ?
import paramiko
from paramiko import SSHClient
class SSH:
    def __init__(self):
        try:
            self.ssh = SSHClient()
            self.ssh.load_system_host_keys()
            self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
            self.ssh.connect(hostname='172.20.0.1', port='22', username='root', password='root')
        except:
            print('Usuario ou senha Invalido')
    def exec_cmd(self, cmd):
        stdin, stdout, stderr = self.ssh.exec_command(cmd)
        if stderr.channel.recv_exit_status() != 0:
            print(stderr.read())
        else:
            print(stdout.read())
if __name__ == '__main__':
    ssh = SSH()
    stdin, stdout, stderr = ssh.ssh.exec_command("scp root@estacao1:/home/pos/log/arqEspelho /retaguarda/")
    retorno = stdout.readlines(), stderr.readlines()
    print(retorno)
Thanks in advance.