I'm having some problems trying to print through a ssh tunnel. I'd like to print from my laptop to a network
printer (Toshiba es453, for what matters) which is in a local network. I can reach the local network using a gateway.
So far I did the following:
ssh -N -L19100:<Printer_IP>:9100 <username>@<ssh_gateway>
Basically i just mapped the port 19100 of my laptop directly to the input port of the
printer, passing through the gateway. So far, so good.
Then, i tried to install on my laptop a new
printer with the GUI config tool of ubuntu, so that the new
printer is on localhost at port 19100 (as APP Socket/HP Jet Direct) , then I provided the proper driver of the
printer. In theory, once the tunnel is open I should be able to print from any program just selecting this
printer. Of course, it does not work. :-)
The document hangs in the queue with status Processing while in the shell where I set up the tunnel I get these errors on failing opening channels
debug1: Local forwarding listening on ::1 port 19100.
debug1: channel 0: new [port listener]
debug1: Local forwarding listening on 127.0.0.1 port 19100.
debug1: channel 1: new [port listener]
debug1: Requesting
[email protected]
debug1: Entering interactive session.
debug1: Connection to port 19100 forwarding to 195.220.21.227 port 9100 requested.
debug1: channel 2: new [direct-tcpip]
debug1: Connection to port 19100 forwarding to 195.220.21.227 port 9100 requested.
debug1: channel 3: new [direct-tcpip]
channel 2: open failed: connect failed: Connection timed out
debug1: channel 2: free: direct-tcpip: listening port 19100 for 195.220.21.227 port 9100, connect from ::1 port 44434, nchannels 4
debug1: Connection to port 19100 forwarding to 195.220.21.227 port 9100 requested.
debug1: channel 2: new [direct-tcpip]
channel 3: open failed: connect failed: Connection timed out
debug1: channel 3: free: direct-tcpip: listening port 19100 for 195.220.21.227 port 9100, connect from ::1 port 44443, nchannels 4
channel 2: open failed: connect failed: Connection timed out
debug1: channel 2: free: direct-tcpip: listening port 19100 for 195.220.21.227 port 9100, connect from ::1 port 44493, nchannels 3
debug1: Connection to port 19100 forwarding to 195.220.21.227 port 9100 requested.
debug1: channel 2: new [direct-tcpip]
As a further debugging test I tried the following. From a machine inside the local network I did a telnet <IP_printer> 9100, got access, wrote some random thing, closed the connection and correctly I got a print of what I had written. So the port and the ip of the
printer should be correct.
I tried the same from my laptop with the tunnel opened, the telnet succeeded but, again, the
printer didn't print anything, getting the usual channel x: open failed: errors.
I'm not a great expert on the matter, I just thought that in theory it was possible to do something like that, but maybe there is something that I didn't consider or I did wrong.
Any clue?
Thanks!
Simone
[update]
As further debugging test, I tried to replicate the procedure from a machine in the local network. From that machine, I did
ssh -N -L19100:<IP_printer>:9100 <username>@<ssh_gateway>
(note that now the machine, the gateway and the
printer are in the same local network) then I tried again the telnet test with telnet localhost 19100, I got access and everything, but I didn't get the print but the usual error
channel 2: open failed: connect failed: Connection timed out
Maybe I am missing some other connection to be forwarded or maybe this is not allowed by the administrators.
Of course, if I connect via ssh tunneling to the local machine from my laptop through the gateway, I can successfully print using the lpr command (from the local machine). But this is what I would like to avoid (yes, I'm lazy...:-), I would like to have a more 'elegant' and transparent way to do that.