paramiko python 모듈 "find"와 "scp"에서 두 개의 명령을 사용하고 있습니다. 찾기 명령이 올바르게 작동하고 올바른 출력을 제공하지만 scp가 출력을 제공하지 않습니다. 나는 다음 코드를 시도 :paramiko에서 scp 명령을 사용하는 방법
import paramiko
class SSH:
def ssh_Connection(self):
try:
self.ssh = paramiko.SSHClient()
self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
self.ssh.connect('host_name',username='user',password='pass')
except Exception, e:
print "================================================"
print 'ERROR: Remote connection failed with %s' % e
print "================================================"
def ssh_Commands(self):
try:
stdin, stdout, stderr = self.ssh.exec_command('find /result/main/ -name "*new.txt*"')
for line in stdout:
a = line.strip('\n')
print a
if a:
cmd = 'scp -r %s [email protected]:/results/main/' % a
print cmd
stdin, stdout, stderr = self.ssh.exec_command(cmd)
print stdout.read()
print stderr.read()
self.ssh.close()
except Exception, e:
print "================================================"
print 'ERROR: Commands Execution failed with %s' % e
print "================================================"
if __name__ == "__main__":
a = SSH()
a.ssh_Connection()
a.ssh_Commands()
하지만이 프로그램은 ...
Throwing an error:
Host key verification failed.
lost connection
어떻게 paramiko에 scp를 사용할 수 있습니다 .. 나를 위해 어떤 생각을 작동하지?
scp -o UserKnownHostsFile =/dev/null -o StrictHostKeyChecking = no -r % s [email protected]을 사용하여 'scp -r % s [email protected] :/results/main /'% a를 대체했습니다. 56.32 :/results/main/'% a 아무 것도 표시하지 않고, find 명령 출력도 표시하지 않습니다. –
'host_name'에 sshing을 시도하고 수동으로 명령을 수행하여 작동하는지 확인하십시오. – robertklep
에 1을 표시 경고 : 알려진 호스트 목록에 영구적으로 '192.168.56.32'(RSA)가 추가되었습니다. –