SSH Port Forward / Tunneling Service
General Steps
Assumed is that a user on the targeted system exists.
For example userremote.
- Create the ssh-key for the service to identify with.
- Add the ssh public key to targeted user on the target system.
- Create the service.
- Allow users to use and/or manage printers.
- Add the printer using KDE Plasma
1) Create the SSH-KEY for a Printer Service
As user root create an ssh-key identity file.
Option
-N ""prevents asking for a passphrase which cannot be used in this case.
The example uses type
rsaand size 2048 for no reason at all.
2) Add the SSH Public Key on the Target System
As an example the target user and system are remote and hostname-target.
When no login is allowed of user remote then copy or append the content of
file ~/.ssh/id_rsa-printer-tunnel.pub to ~/.ssh/auhorized_keys on the targeted system.
3) Create the Service
For creating a service a file /etc/systemd/system/ssh-tunnel.service
is created having the following content which tunnels the printers ports 9100 and 80
respectively to ports 9100 and 8081 to localhost.
The printers web-application is accessible through localhost:8081
The printer-ip can also be a hostname.
[Unit]
Description = SSH Tunnel Service
After = network.target
[Service]
ExecStart = /usr/bin/ssh -N -i /root/.ssh/id_rsa-printer-tunnel -L 9100:printer-ip:9100 -L 8081:printer-ip:80 user@remote_host
User = root
Restart = always
RestartSec = 10
[Install]
WantedBy = multi-user.target
Reload systemd to pick up the new service.
Enable the service so that it starts at boot.
Start the service.
Check the service.
Stop the service.
4) Allow Users to use Printers
Add user to lp group for usage and to the lpadmin group for administration.
5) Add the Printer using KDE Plasma
Some prerequisite packages need to be installed to do this.
How to do this driverless is not figured out yet.
So for this to work a PPD-file is needed of the printer.
As a regular user, part of the lpadmin group, open the KDE Plasma 'System Settings'
from the start menu or from the command-line (Alt+F2) execute systemsettings kcm_printer_manager.
- Click on the top-left button in the Printers window named 'Add Printer'.
- Choose the 'Manual URI' and in the 'Connection' field enter
socket://localhost:9100and click 'Next'. - Select 'Menually provide a PPD file:' and enter the filepath.