1
기본적으로 파이썬에서 중첩 된 SSH SSH 세션을 통해 scp를 수행하는 데 문제가 있습니다. 내 로컬 컴퓨터에서 다른 서버로 SSH를 설정하기 위해 paramiko
을 사용했습니다. 이것을 A과 A에서 호출하겠습니다. 파일을 scp하고 싶습니다. f을 서버에 B으로 보냅니다. 두 서버 모두 동일한 암호를 사용합니다. 다음 코드입니다.파이썬의 paramiko에서 중첩 된 ssh 세션의 scp
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname=hostname, username=username, password=password)
chan = ssh.invoke_shell()
chan.send('scp f [email protected]:.')
buff = ''
while not buff.endswith('\'s password: '):
resp = chan.recv(9999)
buff += resp
chan.send(password + '\n')
buff = ''
while not buff.endswith('$ '):
resp = chan.recv(9999)
buff += resp
왜 이것이 작동하지 않는 지 잘 모르겠습니다. 어떤 도움을 주셔서 감사합니다, 많이 고마워요!