ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('',22,'root','12345',timeout=5)
stdin, stdout, stderr = ssh.exec_command('cd /root/epoll/')
stdin, stdout, stderr = ssh.exec_command('pwd')
上边的代码输出应该是 /root/epoll/,但结果却是 /root ,即使用root登陆的缺省目录
原因是exec_command为单个会话,执行完成之后会回到登录时的缺省目录
修改为这样执行结果则为预期的 /root/epoll 目录
stdin, stdout, stderr = ssh.exec_command('cd /root/epoll/;pwd')