2 ms·
cat | sudo tee somefile > /dev/null is still my favorite way to paste text into an ssh session and save it to a protected file.
by x3n0ph3n3 2y ago
cat | sudo tee somefile > /dev/null
is still my favorite way to paste text into an ssh session and save it to a protected file.
- pbaam 2y agoThe cat command can be omitted there, as tee reads from standard input by default, even if stdin points to a terminal. I was going to comment an actually useful (and unavoidable in bash) use of cat and ssh, which is to do do nothing with standard input and redirect it to a file: <file ssh 'cat >file' And you could just use scp, but I've found clients without scp and servers with the SFTP subsystem disabled.
- x3n0ph3n3 2y agoI want do paste from my clipboard, not copy another file.
- pbaam 2y agoI know, it's intentionally unrelated. But if you read my first sentence, you can do what you are interested in without using cat. sudo tee somefile > /dev/null And you will be able to paste from your clipboard or write anything you want. Without cat or piping.