Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On the remote server, I use lp command to print documents. I can connect to this server through SSH.

How can I print a file directly from my local computer using that printer?

share|improve this question
up vote 5 down vote accepted

Basically, having lp (executed by ssh on the remote machine) read from STDIN which is provided outside the ssh-call like this should work:

cat file-to-print | ssh user@remotehost "lp -"

For more comfort, have a look at this guy's script that gives CUPS a sshlpr://-backend.

share|improve this answer

Depending on which printing system is running on the server, you may be able to run the same lp directly on your client machine and use SSH to forward its connection to the server.

For example, CUPS, which is the printing system of OSX and the most common on Linux nowadays, listens on port 631 (that's the standard IPP port). LPD, the traditional unix printing protocol, listens on port 515.

So if the printing system is CUPS, install a CUPS client on your local machine, and try

ssh -L 631:localhost:631 server.example.com sleep 999999999 &

Then run lpq or lpstat and see if you can reach the printers.

If you find a working configuration, put the SSH command above in a session startup script, or define a host alias with the appropriate LocalForward directive in ~/.ssh/config.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.