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.

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.