python ssh连接远程并wget大文件

195 阅读1分钟

1、设置免密

import ssh
ssh.make_ssh_no_password(remote_ip, 'username', 'password')

2、设置关闭验证并执行命令

command = 'wget XXX'
ssh_cmd = 'ssh -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null %s' % remote_ip
cmd = '%s "%s"' % (ssh_cmd, command)
process_result = test_stub.execute_shell_in_process(cmd, tmp_file)