How to print from remote over SSH to local LAN printer?

8,988

Seems that port 515 is for the earlier lpd implementation for Unix printing. CUPS uses port 631 for IPP printing. If one does not have root privileges, one cannot use port 631. Instead, use a port > 1024, then point CUPS at that port for printing on the local printers. Sample incantation for ssh that works for CUPS, assuming you do not have root privileges:

ssh -R 6311:localhost:631 remotehost

To test for success, assuming the administrator on localhost set up a default printer queue, issue the following command on remotehost:

lpq -h localhost:6311

Jobs can be submitted on the command line using:

lpr -H localhost:6311 files-to-print
Share:
8,988

Related videos on Youtube

casualunixer
Author by

casualunixer

Updated on September 18, 2022

Comments

  • casualunixer
    casualunixer almost 2 years

    OK, so it is fairly straight forward to to run apps from a remote server on my local X screen as though they were local apps. The question is, when trying to print, the remote app only sees printers on the remote side.

    Is it possible (surely it is) to port forward the local CUPS server to the remote session? If so, how? I have tried using the -L option and the printer (515) service, but to no avail.

    • Admin
      Admin over 12 years
      Possible duplicate of SF: "Printing on a local printer from SSH remote session"; one answer there has details on SSH and mentions that -R might be what you're looking for.
    • Admin
      Admin over 12 years
      The answers for the SF question, which is on another site, do not help much either. The closest I can get is the error "connect_to localhost port 515: failed."
    • Admin
      Admin over 12 years
      Hmm...have you tried using an unprivileged port on the remote side? (I.e. see @Gilles comment in the linked SF answer, try using ssh -R 515:localhost:5515)
  • Ungeheuer
    Ungeheuer over 7 years
    How would I do this if I were, say, in another state with my machine and trying to print to my printer back home?