I want connect to my Ubuntu server using a service account but perform file transfer operations on behalf of another user. My sshd_config
has the following content (among other stuff):
PubKeyAuthentication yes
PasswordAuthentication yes
Subsystem sftp /usr/lib/openssh/sftp-server
I have tried the following code but without any success:
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()
This is the error I see when I run this code:
IOError: [Errno 13] Permission denied