title: SSH invocation of a subsystem SFTP using command line
body: <p>I am facing a problem where I have an SFTP server (with no SSH shell access).  </p>
  
  <p>When from a client machine I do SFTP request it works:</p>
  
  <pre><code>sftp username@remote_IP
  </code></pre>
  
  <p>Then if I do a SSH request it hangs</p>
  
  <pre><code>ssh -l username -s remote_IP sftp
  </code></pre>
  
  <p>But the <code>ssh</code> man page suggest that</p>
  
  <pre><code>-s      May be used to request invocation of a subsystem on the remote
          system.  Subsystems facilitate the use of SSH as a secure
          transport for other applications (e.g. sftp(1)).  The subsystem
          is specified as the remote command.
  </code></pre>
  
  <p>Does SSH server at remote server must enable this or there is some other way out for this?  </p>
  
  <p>Adding verbose logs .... let me first share you the <code>sftp</code> verbose mode logs which suggests: </p>
  
  <pre><code>debug1: Authentication succeeded (publickey)
  debug1: fd 5 setting O_NONBLOCK
  debug2: fd 6 is O_NONBLOCK
  debug2: TCP receive buffer size: 49640 B
  debug1: SSH receive window size: 198560 B
  debug1: channel 0: new [client-session]
  debug3: ssh_session2_open: channel_new: 0
  debug1: send channel open 0
  debug1: Entering interactive session.
  debug2: callback start
  debug1: ssh_session2_setup: id 0
  debug1: Sending subsystem: sftp
  debug1: channel request 0: subsystem
  debug2: callback done
  debug1: channel 0: open confirm rwindow 2097152 rmax 32768
  debug2: Remote version: 3
  debug3: Sent message fd 5 T:16 I:1
  debug3: SSH_FXP_REALPATH . -&gt; /root
  sftp&gt; pwd
  </code></pre>
  
  <p>Now I am showing the verbose output of <code>ssh -l username -s remote_IP sftp</code></p>
  
  <pre><code>debug1: Authentication succeeded (publickey).
  debug1: channel 0: new [client-session]
  debug3: ssh_session2_open: channel_new: 0
  debug2: channel 0: send open
  debug1: Entering interactive session.
  debug2: callback start
  debug2: client_session2_setup: id 0
  debug1: Sending subsystem: sftp
  debug2: channel 0: request subsystem confirm 1
  debug2: fd 4 setting TCP_NODELAY
  debug2: callback done
  debug2: channel 0: open confirm rwindow 2097152 rmax 32768
  debug2: channel_input_status_confirm: type 99 id 0
  debug2: subsystem request accepted on channel 0
  </code></pre>
  
  <p>This is where it hangs. </p>
  
  <p>The problem in short is <em>"If SFTP works and is enabled on server what happens to <code>ssh</code> which is calling subsystem <code>sftp</code> on remote server"</em>? What exactly is required at server end or as a matter of fact at client side to make it work?</p>
  
  <p>Please clarify my basic understanding, if I have understood something wrong.  </p>