title: Python: paramiko SCPException connection timeout error
body: <p>From one Windows server i have a python script that connects to a remote Linux host and transfers some data via SSH/SCP. The script is scheduled to execute every morning via the WindowsTaskScheduler of the local server. </p>
  
  <p>The problem i have is that sometimes (not Always strangely enough, and the last days this happens more often) the execution never completes as i get a connection timeout error. From the log of the script:</p>
  
  <pre><code>*Traceback (most recent call last):
    File "D:\App\Anaconda3\lib\site-packages\paramiko\channel.py", line 665, in recv out = self.in_buffer.read(nbytes, self.timeout)
    File "D:\App\Anaconda3\lib\site-packages\paramiko\buffered_pipe.py", line160, in read raise PipeTimeout() paramiko.buffered_pipe.PipeTimeout
  
  During handling of the above exception, another exception occurred:
  Traceback (most recent call last):
    File "D:\App\Anaconda3\lib\site-packages\scp.py", line 314, in _recv_confirm
      msg = self.channel.recv(512)
    File "D:\App\Anaconda3\lib\site-packages\paramiko\channel.py", line 667, in recv
      raise socket.timeout()socket.timeout
  
  During handling of the above exception, another exception occurred:
  Traceback (most recent call last):
    File "script.py", line 235, in &lt;module&gt;
      copy_file_to_remote(LOCAL_FOLDER, file_path, DESTINATION_FOLDER, ssh)
    File "script.py", line 184, in copy_file_to_remote
      scp.put(win_path, linux_path)
    File "D:\App\Anaconda3\lib\site-packages\scp.py", line 154, in put
      self._send_files(files)
    File "D:\App\Anaconda3\lib\site-packages\scp.py", line 255, in _send_files
      self._recv_confirm()
    File "D:\App\Anaconda3\lib\site-packages\scp.py", line 316, in _recv_confirm
          raise SCPException('Timout waiting for scp response')
      scp.SCPException: Timout waiting for scp response*
  </code></pre>
  
  <p>My question is if it is possible to maximize the connection timeout limit in the ssh/scp funtions used in the script or in general how can i make my script to reestablish the connection, keep it open with keepalives or something similar. </p>
  
  <p>It would be also nice if there is way to know at which side of the connection the problem exists, local server or remote machine. This could help a lot for troubleshooting. Any ideas/help very much appreciated!</p>