Assumed is that a user on the targeted system exists.
For example userremote.
As user root create an ssh-key identity file.
Option
-N ""prevents asking for a passphrase which cannot be used in this case.
ssh-keygen -b 2048 -t rsa -C printer-tunnel -f ~/.ssh/id_rsa-printer-tunnel -q -N ""
The example uses type
rsaand size 2048 for no reason at all.
As an example the target user and system are remote and hostname-target.
ssh-copy-id i ~/.ssh/id_rsa-printer-tunnel.pub remote@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.
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.
systemctl daemon-reload
Enable the service so that it starts at boot.
systemctl enable ssh-tunnel.service
Start the service.
systemctl start ssh-tunnel.service
Check the service.
systemctl status ssh-tunnel.service
Stop the service.
systemctl stop ssh-tunnel.service
Add user to lp group for usage and to the lpadmin group for administration.
usermod -aG lp <username>
usermod -aG lp lpadmin <username>
Some prerequisite packages need to be installed to do this.
apt install cups printer-driver-cups-pdf print-manager
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.
socket://localhost:9100 and click 'Next'.