fabric学习

1.通过connection连接远程主机,并执行命令

python 复制代码
from fabric import connection

con1 = connection.Connection(host='10.10.102.198', user='root', port=22, connect_kwargs={"password":"HC@Cloud2022CN"})
con1.run('free -h')

2.上传压缩文件到主机指定目录下,并解压

python 复制代码
con1.put('test.tar.gz', '/root/dockerfile/svn2git/fabric')
con1.run('tar -zxvf /root/dockerfile/svn2git/fabric/test.tar.gz -C /root/dockerfile/svn2git/fabric/')
con1.run('ls /root/dockerfile/svn2git/fabric')

3.从目标服务器跳转到另一台服务器,pty=True

python 复制代码
con1.run('ssh root@10.10.102.148',pty=True)
相关推荐
一隅论数智1 天前
给AI一张“业务概念地图“:本体如何从哲学走向企业智能
大数据·人工智能·经验分享·笔记·学习·学习方法·政务
默_笙1 天前
🍙 给每个请求过安检:FastAPI 是怎么把校验写进类型注解的
python
XiHongShi20161 天前
STM32F407 RTC定时器例程,建议保存
stm32·单片机·学习
qq_426003961 天前
启动playwright录制codegen生成自动化测试脚本
python·自动化
虎头金猫1 天前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺
运维·服务器·网络·python·容器·beautifulsoup·pandas
长沙三为智能科技1 天前
家政小程序开发从0到上线:五阶段交付流程与验收清单
python
爱吃苹果的日记本1 天前
离散数学第六课
学习·离散数学
伞伞悦读1 天前
【第38期】Python 模块与包详解:import、from、模块搜索路径、包结构和 __init__
开发语言·python
只睡四小时1 天前
Canvas 弹道联机实战:700 行 + 固定时间步长
python·websocket·html5·游戏开发·canvas