- python连接ssh
- 运行脚本
- ssh登录参数保存与读取:
import json
my_dict = {"host": "00.00.00.00","port": 22,"user": "root", "pw": "password"}
# 保存文件
tf = open("config.json", "w")
json.dump(my_dict,tf)
tf.close()
# 读取文件
tf = open("config.json", "r")
new_dict = json.load(tf)
print(new_dict)
- 直接新建
config.json
文件,其样式如下:
{
"host": "00.00.00.00",
"port": 22,
"user": "root",
"pw": "password"
}