client.exec_command("cmd ...")就像命令ssh user@host "cmd ..."等等
client.exec_command('cd dir2')client.exec_command('ls')就像
ssh user@host 'cd dir2' # this would not affect the following `ls'ssh user@host 'ls'
。因此,您需要这样做:
client.exec_command('cd dir2; ls')就像
ssh user@host 'cd dir2; ls'



