Sample Header Ad - 728x90

How to pipe a remote file to stdout over scp or sftp?

43 votes
4 answers
42323 views
Using ssh, it is easy to print the contents of a file using ssh host 'cat file.txt' When ssh is disabled, and only SFTP is enabled, running the previous command gives the following error: > This service allows sftp connections only. To work-around this issue, I could create a temporary file using scp or sshfs (as shown below), but that looks really ugly. What is the proper way to print the contents of a remote file when SSH is disabled? mkdir tmpdir sshfs host: tmpdir cat tmpdir/file.txt fusermount -u tmpdir # This does not work! scp -v host:file.txt . shows # "Sink: This service allows sftp connections only." scp host:file.txt . cat file.txt rm file.txt
Asked by Rob W (998 rep)
Jul 28, 2014, 04:40 PM
Last activity: Mar 7, 2025, 08:34 PM