title: Running a remote command through SSH but in the background
body: <p>My use case is as follows. I have to list files on a remote machine and I am using SSH to accomplish this</p>
  
  <p>The command looks like this</p>
  
  <pre>/usr/bin/ssh -2 remote_user@remote_host ls -l remote_dir</pre>
  
  <p>This works fine and I get the ls output</p>
  
  <p>But it errors out when I run it with nohup or in the background. The process just quits. For instance the below command just fails to give any output</p>
  
  <pre>nohup /usr/bin/ssh -2 remote_user@remote_host ls -l remote_dir &</pre>
  
  <p>When run in the debug mode I see this error. It considers all the connections as closed</p>
  
  <pre>
  debug2: channel 0: read&lt;=0 rfd 4 len -1^M
  debug2: channel 0: read failed^M
  debug2: channel 0: close_read^M
  debug2: channel 0: input open -> drain^M
  debug2: channel 0: ibuf empty^M
  debug2: channel 0: send eof^M
  debug2: channel 0: input drain -> closed^M
  debug2: tcpwinsz: 87380 for connection: 3^M
  debug2: tcpwinsz: 87380 for connection: 3^M
  debug2: channel 0: rcvd eof^M
  debug2: channel 0: output open -> drain^M
  debug2: channel 0: obuf empty^M
  debug2: channel 0: close_write^M
  debug2: channel 0: output drain -> closed^M
  debug1: client_input_channel_req: channel 0 rtype exit-status reply 0^M
  debug2: channel 0: rcvd close^M
  debug3: channel 0: will not send data after close^M
  debug2: tcpwinsz: 87380 for connection: 3^M
  debug2: channel 0: almost dead^M
  debug2: channel 0: gc: notify user^M
  debug2: channel 0: gc: user detached^M
  debug2: channel 0: send close^M
  </pre>
  
  <p>How can I run the remote file listing in the background and I don't want to redirect the standard out and standard error?</p>
  
  <p>Can someone explain what is happening here?</p>