title: Read all files from an ssh connection folder to R directly?
body: <p>I would like to read all csv files from a folder located on an ssh server to R. I am using the following code:</p>
  <pre><code>files_list&lt;- as.vector(
  read.delim(
  pipe('ssh -i &quot;/path/to/ssh/key&quot; user@1.2.3.4 &quot;ls /home/ubuntu/data_folder&quot;'), 
  header = F, 
  sep = )[,1])
  
  
  
  df&lt;- list()
  
  for (i in 1: length(files_list)){
  tmp&lt;- noquote(paste0(&quot;\'ssh -i \&quot;/path/to/ssh/key\&quot; user@1.2.3.4 \&quot;cat /home/ubuntu/data_folder/&quot;,files_list[i],&quot;\&quot;\'&quot;))
  df[[i]]&lt;- read.csv(
    header = F, 
    sep = &quot;,&quot;,
    pipe(
      tmp
      )
  )
  
  }
  </code></pre>
  <p>However, running this code gives me the following error:</p>
  <pre><code>sh: ssh -i &quot;/path/to/ssh/key&quot; user@1.2.3.4 &quot;cat /home/ubuntu/data_folder/file.csv&quot;: No such file or directory
  
  </code></pre>
  <p>When I paste the output of tmp variable into the pipe command then it is able to read the file. Eg:</p>
  <pre><code>df&lt;- read.csv(
    header = F, 
    sep = &quot;,&quot;,
    pipe(
      'ssh -i &quot;/path/to/ssh/key&quot; user@1.2.3.4 &quot;cat /home/ubuntu/data_folder/file.csv'
      )
  )
  </code></pre>
  <p>I am trying to understand why passing tmp variable into pipe doesn't work, but the output of tmp variable does.</p>
  <p>Thanks</p>