【发布时间】:2018-04-26 06:11:00
【问题描述】:
我想使用服务帐户连接到我的 Ubuntu 服务器,但代表另一个用户执行文件传输操作。我的sshd_config 有以下内容(除其他外):
PubKeyAuthentication yes
PasswordAuthentication yes
Subsystem sftp /usr/lib/openssh/sftp-server
我尝试了以下代码,但没有任何成功:
t = paramiko.Transport(('<address>', <port>))
t.connect(username='serviceAccount', password='<password>')
channel = t.open_session()
channel.exec_command('sudo su -l <other user> -c /usr/lib/openssh/sftp-server')
sftp = t.open_sftp_client()
file = sftp.file("<some path>", "w", bufsize=...)
file.write(...)
file.close()
sftp.close()
channel.close()
t.close()
这是我在运行此代码时看到的错误:
IOError: [Errno 13] Permission denied
【问题讨论】:
标签: python ssh sftp paramiko su