Re: 如何ssh到另外一台机器上执行 程序
"Jian Qin" <[email protected]>
| Newsgroups | gmane.comp.python.chinese |
|---|---|
| Message-ID | <[email protected]> |
原来Jiahua Huang给的例子,照这个做就可以了。不过我的程序实现的是ssh到指定的主机上去netcat监听,
然后再起一个sender.py向指定的主机
发送信息,通过信息是否收到和正确来判断gateway上的iptables是否正确有效。用chan.send
()总有点问题,可能是我没设置正确,所以我用的是
chan.exec_command()
你可以先看看paramiko的文档
import paramiko
t = paramiko.Transport(('192.168.0.77', 6667))
t.connect(username='YYYYYYY', password='XXXXXXX')
chan = t.open_session()
chan.get_pty()
chan.invoke_shell()
chan.send('nc -l -p 6668 \n')
print chan.recv(1024)
在08-1-15,吴亮 <[email protected]> 写道:
>
> __________
> > python-chinese
> > Post: send [email protected]
> > Subscribe: send subscribe to [email protected]
> > Unsubscribe: send unsubscribe to [email protected]
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> 大家有没有现成的关于使用paramiko进行ssh和scp的代码,
> 有的话发一个给我参考一下吧,
> 我给写一个关于ssh的脚本,
> 谢谢了
>
> _______________________________________________
> python-chinese
> Post: send [email protected]
> Subscribe: send subscribe to [email protected]
> Unsubscribe: send unsubscribe to [email protected]
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>
_______________________________________________
python-chinese
Post: send [email protected]
Subscribe: send subscribe to [email protected]
Unsubscribe: send unsubscribe to [email protected]
Detail Info: http://python.cn/mailman/listinfo/python-chinese