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