【发布时间】:2021-04-12 02:59:54
【问题描述】:
我正在使用 SSHTunnelForwared 并使用以下代码成功进入远程服务器:
with SSHTunnelForwarder((ssh_host, ssh_port), ssh_username=ssh_user,
ssh_password=ssh_password,
remote_bind_address=("127.0.0.1", 3306)) as tunnel:
我现在想从服务器内部的路径中将文件读入 python。假设路径是/home/user/file.json
如果我做类似的事情
with open('/home/user/file.json','r') as f:
data = json.loads(f)
程序抛出错误提示:
FileNotFoundError: [Errno 2] No such file or directory: '/home/user/file.json'
显然找不到该文件。我需要做什么才能找到目录?我在ssh 块内工作,所以我可以访问tunnel 对象。
【问题讨论】:
标签: python ssh remote-access ssh-tunnel