Search code examples
pythonsftpparamikowinscppysftp

Use custom command to start SFTP server in pysftp/Paramiko


In WinSCP is an option to edit the SFTP server command/path (in the protocol options):

winscp image

Is there also such an option in pysftp/Paramiko or in an another SFTP package for Python?

Thanks!


Solution

  • What that option in WinSCP does is that it runs SFTP over the "exec" channel, instead of the "sftp subsystem" channel. An (untested) equivalent in Python Paramiko:

    ssh = paramiko.SSHClient()
    
    # authenticate here
    
    chan = ssh.get_transport().open_session()
    chan.exec_command("/path/to/sftp-server")
    sftp = paramiko.SFTPClient(chan)