Need to combine “Sudo” and “ScpTo” examples of JSch
问题 I'm unsuccessful with combining "Sudo" and "ScpTo" cases. I noticed, that both work through "exec" channel. Clean "ScpTo" case finishes with "Permission denied" message. "Sudo" case Channel channel = session.openChannel("exec"); ((ChannelExec) channel).setCommand("sudo -S -u <supervisor> whoami"); works fine. When I connect to my server through FarManager I write server option: sudo su -l <supervisor> -c /usr/libexec/openssh/sftp-server Also, I can run usual SFTP client like this: sftp -s