1
import paramiko

class SSHConnection(object):
    def __init__(self, host, username, password, port=22):
        self.sftp = None
        self.sftp_open = False
        self.transport = paramiko.Transport((host, port))
        self.transport.connect(username=username, password=password)

    def openSFTPConnection(self):
        if not self.sftp_open:
            self.sftp = paramiko.SFTPClient.from_transport(self.transport)
            self.sftp_open = True

    def get(self, remote_path, local_path=None):
        self.openSFTPConnection()        
        self.sftp.get(remote_path, local_path)        

    def put(self, local_path, remote_path=None):
        self.openSFTPConnection()
        self.sftp.put(local_path, remote_path)

    def close(self):
        if self.sftp_open:
            self.sftp.close()
            self.sftp_open = False
        self.transport.close()

if __name__ == "__main__":
    host = '192.168.43.183'
    username = "TimberMedia"
    pw = "Welcome@123"

    origin = '/home/maruthi/Desktop/python/hello.py'
    dst = '/home/TimberMedia/Pictures/hello.py'

    ssh = SSHConnection(host, username, pw)
    ssh.put(origin, dst)
    ssh.close()

i got this error, below is the error,

paramiko.ssh_exception.AuthenticationException: Authentication failed.

i am trying to connect remote server with paramiko but i am getting this error , where am i going wrong, thanks in advance.

Raghunath
  • 11
  • 1
  • 5
  • This similar thread may help. [Paramiko AuthenticationException issue](https://stackoverflow.com/questions/4135261/paramiko-authenticationexception-Issue) – Bezz Jun 14 '17 at 00:20
  • Another similar thread. https://stackoverflow.com/questions/14274566/paramiko-protocol-error-expected-packet-ssh-msg-userauth-request-got-ssh-msg-s – Isidro Martínez Jul 15 '17 at 00:19

0 Answers0