-2
나는이 코드는 사용자 이름, 비밀 번호 및 호스트의 도움으로 원격 sftp 서버에 연결할 수 있지만 또한 포트 번호를 포함해야합니다, 그들 중 하나가 어떻게 포함 할 수있는 포트를 포함시킬 수 있습니다 이 코드의 숫자와이 코드의 숫자 'parmiko.util.log_to_file (log_filename)'log_filename에 대한 하드 코드는 무엇입니까 ??Iam은 유닉스 환경에서이 코드를 실행합니다.파이썬 코드 sftp 서버에 연결
import os
import paramiko
server, username, password = ('host', 'username', 'password')
ssh = paramiko.SSHClient()
parmiko.util.log_to_file(log_filename)
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
' #In case the server's key is unknown,'
#we will be adding it automatically to the list of known hosts
ssh.load_host_keys(os.path.expanduser(os.path.join("~", ".ssh", "known_hosts")))
#Loads the user's local known host file
ssh.connect(server, username=username, password=password)
ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command('ls /tmp')
print "output", ssh_stdout.read() #Reading output of the executed co'mmand
error = ssh_stderr.read()
#Reading the error stream of the executed command
print "err", error, len(error)
#Transfering files to and from the remote machine'
sftp = ssh.open_sftp()
'sftp.get(remote_path, local_path)'
sftp.put(local_path, remote_path)
sftp.close()
ssh.close()
있어 내가 한 전에 두 번째 : P +1 manual
예를 참조하십시오 –