I can use ssh or scp to append a remote file to a local file, but I cannot figure out how to do the reverse and append a local file to a remote server.

ssh remote.server cat /path/to/file >> locale-file

Works great (but not with globbing), but how do I reverse it?

1 Answer 1

<localfile ssh remote.server 'cat >> remote_file'

This will send the contents of localfile to the stdin of ssh.

  • ssh -t ... The "-t" isn't helpful here, and it could cause the operation to fail. You're better off leaving it out. ssh remote.server "cat..."
    – Kenster
    Commented Jun 29, 2020 at 16:11
  • yes, ssh -t causes an error (Pseudo-terminal will not be allocated because stdin is not a terminal.), though in my case it still worked.
    – lbutlr
    Commented Jun 29, 2020 at 16:53
  • 1
    The - is not even necessary. Commented Jun 29, 2020 at 23:58
  • 3
    Better to use -T, i.e. not allocate any TTY at all. Commented Feb 15, 2021 at 13:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .