文章目录
SSH(Secure Shell)
安全外壳协议,是建立在应用层基础上的安全协议。
paramiko
安装
conda install paramiko
或 pip3 install paramiko
基本操作
import paramiko
from conf import *
# 创建ssh客户端对象
client = paramiko.SSHClient()
try:
# 首次ssh远程时会提示输入yes或no
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# 远程连接
client.connect(hostname, port, username, password, timeout=20)
# 执行命令
stdin, stdout, stderr = client