Python3 sftp

mardi 13 septembre 2016

Hi,

ich komme mit einem scp/sftp problem nicht weiter

An der Stelle mit dem ssh.connect macht das Ding genau das, einen connect und weil ich dort nur schreibrechte, also rechte zum hochschieben habe, macht es einen Auth fail, wie komme ich da weiter um den File zu schieben

Code:

## SSH Connect Variables
import os
import paramiko
WorkHome = os.environ.get("HOME")
SshUser = 'MyOtherUSer'
SshTarget = 'localhost'
SshFile = WorkHome + '/.ssh/id_rsa'
SshKeyFile = paramiko.RSAKey.from_private_key_file(SshFile)


ssh = paramiko.SSHClient()
ssh.load_system_host_keys()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(SshTarget, username=SshUser, pkey=SshKeyFile)
sftp = ssh.open_sftp()


sftp.put(LocalFile, TargetPath)
sftp.close()
ssh.close()

Gruss Stefan


0 commentaires:

Enregistrer un commentaire

 

Lorem

Ipsum

Dolor