Configuring printing from Yandex Cloud Desktop to a local printer in Linux
This guide will help you configure file printing from Yandex Cloud Desktop to a printer connected to a local Linux machine. The solution is built around a shared folder: print jobs from the cloud environment are saved to a shared folder, the local system intercepting and sending them to a physical printer.
Note
This guide gives an example of connecting a virtual printer for printing into a PDF file. To use a printer connected to your local machine (server), add that printer on the CUPSprinter-driver-cups-pdf PDF printing driver, set up /etc/cups/cups-pdf.conf, create the /tmp/cups-pdf-output folder, or use the PDF verification section.
To configure printing from a Cloud Desktop desktop on a local printer in Linux:
- Get your cloud ready.
- Prepare the infrastructure.
- Configure the local machine.
- Configure the desktop.
- Check the result.
If you no longer need the resources you created, delete them.
Getting started
Sign up for Yandex Cloud and create a billing account:
- Navigate to the management console
and log in to Yandex Cloud or create a new account. - On the Yandex Cloud Billing
page, make sure you have a billing account linked and it has theACTIVEorTRIAL_ACTIVEstatus. If you do not have a billing account, create one and link a cloud to it.
If you have an active billing account, you can navigate to the cloud page
Learn more about clouds and folders here.
Required paid resources
The infrastructure support costs include:
- Fee for using the desktop’s computing resources, disks, and for outbound traffic (see Yandex Cloud Desktop pricing).
- Fee for NAT gateway usage and outbound traffic (see Yandex Virtual Private Cloud pricing).
Prepare the infrastructure
If you do not have a desktop yet, create one:
- Create a network and subnet for the desktop.
- Set up a NAT gateway for the desktop.
- Create a desktop group. When creating it, select an image with a Linux-based OS, e.g., Ubuntu 20.04.
- Create a desktop.
Configure the local machine
Configure your local machine to receive files from the desktop.
-
Install the necessary tools:
- The inotify-tools
utility. - CUPS
print server. - The printer-driver-cups-pdf package for virtual PDF print checks. To configure a physical printer, install that printer’s driver.
- The [Samba]https://en.wikipedia.org/wiki/Samba_(software) package.
Do it by running these commands:
sudo apt update sudo apt install inotify-tools cups printer-driver-cups-pdf samba - The inotify-tools
-
Create a shared folder at
/srv/printdropand set up access permissions for it:sudo mkdir -p /srv/printdrop sudo chown lp:lp /srv/printdrop sudo chmod 0770 /srv/printdropThis folder will be used for file exchange between the desktop and the local machine.
-
Set up Samba:
-
Open
/etc/samba/smb.conf:sudo nano /etc/samba/smb.conf -
Add this code at the end of the file:
[printdrop] path = /srv/printdrop browseable = yes writable = yes guest ok = yes force user = lp force group = lp create mask = 0660 directory mask = 0770
-
-
Configure CUPS:
-
Open
/etc/cups/cups-pdf.conf:sudo nano /etc/cups/cups-pdf.conf -
Find the
Out ${HOME}/PDFor#Out ${HOME}/PDFline and replace it with the following:Out /tmp/cups-pdf-output
-
-
Create a folder at
/tmp/cups-pdf-outputand set up access to it:sudo mkdir -p /tmp/cups-pdf-output sudo chown lp:lp /tmp/cups-pdf-output sudo chmod 755 /tmp/cups-pdf-outputThis folder will store files sent for printing.
Note
For a physical printer, you do not need to configure
/etc/cups/cups-pdf.confand/tmp/cups-pdf-output. Add a printer to CUPS using thehttp://localhost:631admin interface by selecting Administration → Add Printer or using thelpadmincommand. Then, use thelpstat -pcommand to get the queue (physical printer) name. -
Configure the service to watch the shared folder:
-
Create a file named
print-watcher.sh:sudo nano /usr/local/bin/print-watcher.sh -
Paste this code into the
print-watcher.shfile:#!/bin/bash WATCH_DIR="/srv/printdrop" PRINTER="PDF" # locally installed printer USER="lp" # user the print is initiated for inotifywait -m -e close_write,moved_to --format '%w%f' "$WATCH_DIR" | while read FILE; do if [[ "${FILE,,}" == *.pdf ]]; then lp -U "$USER" -d "$PRINTER" "$FILE" && rm -f "$FILE" fi doneNote
For a physical printer, in the PRINTER="PDF" parameter, replace PDF with the physical printer (queue) name.
-
Make the file executable:
sudo chmod +x /usr/local/bin/print-watcher.sh -
Create a service file named
print-watcher.service:sudo nano /etc/systemd/system/print-watcher.service -
Paste this code into the
print-watcher.servicefile:[Unit] Description=Watch printdrop and print files [Service] ExecStart=/usr/local/bin/print-watcher.sh Restart=always User=lp Group=lp [Install] WantedBy=multi-user.target
-
-
Activate the service and restart the printing and file exchange services:
sudo systemctl daemon-reload sudo systemctl restart cups sudo systemctl restart smbd sudo systemctl enable --now print-watcher.serviceResult:
Created symlink /etc/systemd/system/multi-user.target.wants/print-watcher.service → /etc/systemd/system/print-watcher.service. -
Run this command to test the service:
systemctl status print-watcher.serviceResult:
● print-watcher.service - Watch printdrop and print files Loaded: loaded (/etc/systemd/system/print-watcher.service; enabled; preset: enabled) Active: active (running) since ... ... -
Save the public IPv4 address of your local machine. One way to learn it is by using Yandex Internetometer
. You will need this address to mount the shared folder on your desktop.
Configure the desktop
Configure the desktop to send files to the local machine.
-
Connect to the desktop.
-
Install the CUPS server and the cifs-utils package:
sudo apt update sudo apt install cups sudo apt-get install cifs-utils -
Configure the backend for the virtual printer:
-
Create a file named
/usr/lib/cups/backend/printdrop:sudo nano /usr/lib/cups/backend/printdrop -
Paste this code into the file:
#!/bin/bash export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin if test "$#" = "0"; then echo 'file printdrop:/printdrop "PrintDrop" "/printdrop"' exit 0 fi DROP_DIR="/home/<desktop_user_name>/printdrop" mkdir -p /tmp/cups-shared JOBFILE="$6" # if CUPS provides the file as an argument TS=$(date +%s)-$RANDOM OUT="$DROP_DIR/job-$TS.pdf" SHARED_OUT="/tmp/cups-shared/job-$TS.pdf" if [ -n "$JOBFILE" ] && [ -f "$JOBFILE" ]; then cp "$JOBFILE" "$SHARED_OUT" chmod -R 777 /tmp/cups-shared sudo -u <desktop_user_name> /usr/local/bin/copy-as-user.sh "$SHARED_OUT" "$OUT" else cat - > "$SHARED_OUT" sudo -u <desktop_user_name> /usr/local/bin/copy-as-user.sh "$SHARED_OUT" "$OUT" fiSpecify the name of the desktop user you will use to send files for printing.
-
Set up access to the file:
sudo chmod 755 /usr/lib/cups/backend/printdrop sudo chown root:root /usr/lib/cups/backend/printdrop
-
-
Set up access to the shared folder:
-
Create a file named
/usr/local/bin/copy-as-user.sh:sudo nano /usr/local/bin/copy-as-user.sh -
Paste the helper script code:
#!/bin/bash mv "$1" "$2.tmp" mv "$2.tmp" "$2" -
Set up access to the file:
sudo chmod +x /usr/local/bin/copy-as-user.sh sudo chown root:root /usr/local/bin/copy-as-user.sh -
Set up permissions:
sudo visudo -
At the end of the file that opens, paste this line:
lp ALL=(<desktop_user_name>) NOPASSWD: /usr/local/bin/copy-as-user.shSpecify the name of the desktop user you will use to send files for printing.
-
-
Create a virtual printer and activate it:
sudo lpadmin -p DropPrinter -E -v printdrop:/printdrop sudo cupsenable DropPrinter sudo cupsaccept DropPrinterYou will now see a message that a new printer was added.
-
Create a folder for shared folder mounting:
sudo mkdir -p ~/printdrop -
Mount the shared folder:
sudo mount -t cifs //<local_machine_IP_address>/printdrop ~/printdrop -o guest,uid=$(id -u),gid=$(id -g)Specify the IPv4 address you saved earlier.
Check the result
To check the result, send a PDF file for printing.
-
On your desktop, create or download
any PDF file. -
On your desktop, send the PDF file for printing by selecting the new virtual printer.
You will now see a message that the file was added to the printing queue.
-
On your local machine, check the printing queue of the virtual PDF printer.
Troubleshooting
For troubleshooting, use the following commands on your local machine:
-
Viewing CUPS logs related to incoming print jobs:
sudo tail -n 10 /var/log/cups/access_logResult:
... localhost - - [15/Nov/2025:21:55:01 +0000] "POST /printers/PDF HTTP/1.1" 200 394 Create-Job successful-ok localhost - - [15/Nov/2025:21:55:01 +0000] "POST /printers/PDF HTTP/1.1" 200 408591 Send-Document successful-ok -
To view CUPS error logs:
sudo tail -n 10 /var/log/cups/error_logDetailed entries report errors:
... W [15/Nov/2025:21:55:01 +0000] [Job 34] Backend cups-pdf returned status 5 (cancel job) -
To view the PDF files created by the virtual printer:
sudo ls -l /tmp/cups-pdf-output/Result:
total 472 -rw------- 1 lp lp 239840 Nov 17 19:37 job-1763408227-8471-job_2.pdf ...
How to delete the resources you created
To stop paying for the resources you created:
Optionally, delete the subnets, network, and the desktop group.