python - 我如何知道用户是否通过我的 python 脚本中的 ssh 连接到本地计算机?

标签 python ssh

我如何知道用户是否通过我的 python 脚本中的 ssh 连接到本地计算机?

最佳答案

您可以使用os 模块来检查环境变量SSH_CONNECTION 是否存在。

>>> import os
>>> using_ssh = 'SSH_CONNECTION' in os.environ

关于python - 我如何知道用户是否通过我的 python 脚本中的 ssh 连接到本地计算机?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3507980/

相关文章:

python - 如何递归迭代复杂的python对象?

python - 设置 setup.py 用于打包单个 .py 文件和单个数据文件,无需创建任何文件夹

node.js - 使用 Node.js ssh2 模块模拟 ssh 的 ProxyCommand

docker - 通过 ssh 的 Portainer 端点

git - Gerrit复制到gitlab失败

python - 如何从本地文件导入环境变量到Django

python - 如何编写div类属性BeautifulSoup

Python Selenium 'WebDriver' object has no attribute 错误

iphone - iOS : interacting with other applications

git - 在无法访问原始版本的情况下迁移 git 存储库服务器时出现问题