1
基本的に、私はPythonでネストされたSSH sshセッションを介してscpを実行することに問題があります。私はparamiko
を使用して、ローカルマシンから別のサーバにSSHを確立しました。これをAとAとします。私はファイルをscpしたい、fとサーバBと呼ぶ。両方のサーバーに同じパスワードが設定されています。これはコードです:Pythonの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
これはなぜ機能しないのか分かりません。どんな助けもありがとう、ありがとう!