1

How do I upload a local file to a remote machine running over SSH with lsh? There are enough examples on the Internet for ssh but I am interested in doing it with lsh.

Here is what I tried with an MP3 file:

$ cat file.mp3 | lsh -l pi -c aes256-ctr --sloppy-host-authentication raspberrypi.local "cat > file.mp3"
$ lsh -l pi -c aes256-ctr --sloppy-host-authentication raspberrypi.local "cat > file.mp3" < file.mp3
$ tar -c file.mp3 | lsh -l pi -c aes256-ctr --sloppy-host-authentication raspberrypi.local "tar -x"

All of this results in a file named exactly as the file which I am sending but completely empty.

$ ls -l file.mp3
-rwxr-xr-x 1 pi pi 0 Feb 24 06:55 file.mp3

1 Answers1

1

From another look at the documentation I noticed that I've overlooked -f -. -f instructs tar to use an archive file. - represents standard input or standard output respectively. So, this worked:

$ tar -cf - file.mp3 | lsh -l pi -c aes256-ctr --sloppy-host-authentication raspberrypi.local "tar -xf -"

To upload a single file, another example is given in section 3.5 of the Texinfo manual of GNU lsh. It uses input and output reditrection and does not require tar. In the above example, it would be:

$ lsh -l pi -c aes256-ctr --sloppy-host-authentication raspberrypi.local '>file.mp3' <file.mp3

However, that creates just an empty file on my systems as well as

$ >testfile2 <testfile1

I needed to add cat:

$ lsh -l pi -c aes256-ctr --sloppy-host-authentication raspberrypi.local 'cat >file.mp3' <file.mp3