忍者的ssh

sshaolin的Python项目详细描述


[![许可证](https://img.shields.io/github/license/bucknerns/sshaolin.svg?maxage=2592000)(https://github.com/bucknerns/sshaolin/blob/master/license)
[![github问题](https://img.shields.io/github/issues/bucknerns/sshaolin.svg)](https://github.com/bucknerns/sshaolin/issues)



想要一个简单的python ssh接口,它能正常工作!
sshaolin的目标是给你这种体验和更多!
建立在[paramiko]之上(https://github.com/paramiko/paramiko),
sshaolin是一个python接口,它使编写ssh脚本变得简单
多年来您一直想这样做!

sshaolin核心内置了详细的日志记录,它向您显示运行的每个
命令以及直接从日志中解密stdout和
stderr的能力!

还包括用于持久ssh会话(SSHShell)和sftp会话(SFTPShell)的接口两者都很容易使用,并提供了一个伟大的速度
提高,而不是连接和重新连接的每一个行动!

有问题吗?在这里提交(https://github.com/bucknerns/sshaolin/issues)!


<<


建议:
`````
$pip install git+https://github.com/bucknerns/sshaolin
````






<
<
*必须在本地主机运行ssh服务器;22
*必须具有到本地主机的passwordslss ssh-ssh-ssh-auth
``` python
<>$tox
``````
`````` ``` `
/>
要求:

*[paramiko](https://github.com/paramiko/paramiko)
*[Pysocks](https://github.com/anorov/Pysocks)

\br/>
*创建持久的ssh会话!
*创建持久的SFTP会话!
*轻松清理连接(不再手动关闭!)< BR> > BR/>< BR> >服务器'Fo'''作为用户'bar ''密码'BR''BR/> ` Python BR/>从SHOLLIN .Client导入SSHClient
BR/>客户端= SSHClient(主机名=“fo”,用户名=“bar”,密码=“BLAH”)
响应= Client .ExcExtEy命令('LS-LTR)
BR/>它具有退出状态!打印(响应,退出状态)< BR> > BR/>它与STDUT一起出现!
打印(response.stdout)


print(response.stderr)
````














是的username='bar',key_filename='/home/bar/.ssh/id_rsa')
,open('example.txt','r')为fp:
data=fp.read()


使用client.create_sftp()作为sftp:
sftp.write_file(data=data,remote_path='/usr/local/src/example.txt')

当程序退出时,SSHaolin会清理它!
sftp=client.create\u sftp()
sftp.write\u文件(data=data,remote\u path='/usr/local/src/example2.txt')
````


sudong to`privilelegeduser1`,cd dong to`/usr/local/executables`/usr/local/executables`和运行
`perl randomperlscript.pl`
`````python
>```pytholin pytholin.client从sshaolilin.client导入sshcclient客户端sshcclient




shell=client.create_shell()

shell.execute_command('sudo su privelegeduser1')
shell.execute_command('cd/usr/local/executables')
perl嫒response=shell.execute嫒command('perl randomperscript.pl')
shell.close();我们也可以手动关闭!
BR/>如果PrLyReal.ExtIt==0:
打印(“成功”)
否则:
引发异常(“未能正确执行randomperlscript.pl”)
```

分叉[存储库](https://github.com/bucknerns/sshaolin)!
2.做点事情!
3.提交拉取请求!

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
oop Java多态性:如何指示应该使用子类进行比较?   JavaLibGDX:渲染基于可缩放向量的形状的最快方法是什么?   java如何通过可选选项同时检查NPE上对象的字段和条件?如果一切正常,什么都不做,否则抛出异常   java使用camera2获取图像捕获时间   未单击时选中java Recyclerview复选框   java Android Hello world项目未运行   java在网站上发布处理代码?   java如何在jdialog中设置垂直滚动条?   java等待并通知   使用JavaFX在raspberry PI上构建java Maven失败   java处理空值Hazelcast投影   在java中为以下数据选择完美的数据结构   通过ApacheHttpClient将对象的arraylist从Java传递到PHP   使用同步关键字的多线程java等待通知方法   java素数与布尔逻辑   java组织。json。JSONException:JSONArray文本必须以“[”开头