- Share windows printer with linux
- CUPS/Printer sharing
- Contents
- Creating class for multiple printers
- Printer sharing
- DNS-SD advertisement
- Sharing via Internet Printing Protocol
- Sharing via Samba
- Sharing via Line Printer Daemon protocol
- Remote administration
- Kerberos
- Troubleshooting
- Cannot print with GTK applications
- Permission errors on Windows
- Как расшарить принтер в ubuntu?
- 7 ответов
- Шаг1. Открыть общий доступ к принтеру в Ubuntu Linux (через IPP)
- Шаг 2. Подключение share-принтера на Linux-клиенте.
- Шаг 3. Подключение share-принтера на Windows-клиенте.
- How To Share Printer On Network In Linux
- Add Your Printer To Computer
- Accessing A Printer On Another Computer
- Conclusion
Share windows printer with linux
To share a printer on a Windows machine, you must do the following:
- You must have the proper entries in /etc/printcap and they must correspond to the local directory structure (for the spool directory, etc).
- You must have the script /usr/bin/smbprint. This comes with the Samba source, but not with all Samba binary distributions. A slightly modifed copy is discussed below.
- If you want to convert ASCII files to Postscript, you must have nenscript, or its equivalent. nenscript is a Postscript converter and is generally installed in /usr/bin.
- You may wish to make Samba printing easier by having an easy-to-use front end. A simple perl script to handle ASCII, Postscript or created Postscript is given below.
- You could also use MagicFilter to do the above. The details on setting up MagicFilter are given below the perl script. MagicFilter has advantages because it knows how to automatically convert a lot of file formats.
The /etc/printcap entry below is for an HP 5MP printer on a Windows NT host. The entries are as follows:
For more information, see the Printing HOWTO or the man page for printcap.
Make certain that the spool and accounting directories exist and are writable. Ensure that the ‘if’ line holds the proper path to the smbprint script (given below) and make sure that the proper device is pointed to (the /dev special file).
Next is the smbprint script itself. It is usually placed in /usr/bin and is attributable to Andrew Tridgell, the person who created Samba as far as I know. It comes with the Samba source distribution, but is absent from some binary distributions, so I have recreated it here.
You may wish to look at this carefully. There are some minor alterations that have shown themselves to be useful.
Most Linux distributions come with nenscript for converting ASCII documents to Postscript. The following perl script makes life easier be providing a simple interface to Linux printing via smbprint.
Using smbprint to print ASCII files tends to truncate long lines. This script breaks long lines on whitespace (instead of in the middle of a word), if possible.
The source code formatting is done with nenscript. It takes an ASCII file and foramts it in 2 columns with a fancy header (date, filename, etc). It also numbers the lines. Using this as an example, other types of formatting can be accomplished.
Postscript documents are already properly formatted, so they pass through directly.
Now the MagicFilter way. Thanks to Alberto Menegazzi ( flash.egon@iol.it) for this information.
————————————————————— 1) Install MagicFilter with the filter for the printers you need in /usr/bin/local but DON’T fill /etc/printcap with the suggestion given by the documentation from MagicFilter.
2) Write the /etc/printcap like this way (it’s done for my LaserJet 4L):
lp|ljet4l:\ :cm=HP LaserJet 4L:\ :lp=/dev/null:\ # or /dev/lp1 :sd=/var/spool/lpd/ljet4l:\ :af=/var/spool/lpd/ljet4l/acct:\ :sh:mx#0:\ :if=/usr/local/bin/main-filter:
You should explain that the lp=/dev/. is opened for locking so «virtual» devices one for every remote printer should be used.
Example creating with : touch /dev/ljet4l
3) Write the filter /usr/local/bin/main-filter the same you suggest using the ljet4l-filter instead of cat.
#! /bin/sh logfile=/var/log/smb-print.log spool_dir=/var/spool/lpd/ljet4l ( echo «print -» /usr/local/bin/ljet4l-filter ) | /usr/bin/smbclient «\\\\SHIR\\HPLJ4» -N -P >> $logfile
P.S. : here is the quote from the Print2Win mini-Howto about locking and why creating virtual printers
Hint from Rick Bressler :
Good tip sheet. I use something very similar. One helpful tip, this is not a particularly good idea:
lpr does an ‘exclusive’ open on the file you specify as lp=. It does this in order to prevent multiple processes from trying to print to the dame printer at the same time.
The side effect of this is that in your case, eng and colour can’t print at the same time, (usually more or less transparent since they probably print quickly and since they queue you probably don’t notice) but any other process that tries to write to /dev/null will break!
On a single user system, probably not a big problem. I have a system with over 50 printers. It would be a problem there.
The solution is to create a dummy printer for each. Eg: touch /dev/eng.
I have modified the lp entries in the printcap file above to take into account Rick’s suggestion. I did the following:
CUPS/Printer sharing
This article contains instruction on sharing printers from a GNU/Linux system.
Protocol | Linux | Windows | macOS |
---|---|---|---|
Discovery (DNS-SD/mDNS) | CUPS with Avahi | Native support since Windows 10 | Bonjour |
Internet Printing Protocol | CUPS | Control Panel > Programs > Turn Windows features on or off > Print and Document Services > Internet Printing Client | Native support |
SMB shared printer | Samba with CUPS | Native support | Native support |
Line Printer Daemon protocol | CUPS | Control Panel > Programs > Turn Windows features on or off > Print services > LPD Print Service and LPR Port Monitor | Native support |
Contents
Creating class for multiple printers
In CUPS, a class is a group of printers which appears to clients as a single printer. When a client selects to print to the class, CUPS selects any printer in the group to accept the print job. This may be especially useful when one printer from the class must be removed. If it is excluded from the class, end users will not notice any change because the print job will be queued to another printer in the class. Creating and managing classes can be done from CUPS Web GUI.
Printer sharing
This article or section needs expansion.
DNS-SD advertisement
To announce the printer to the network over DNS-SD/mDNS (Bonjour in Apple world), Avahi must be installed and running on the server.
To enable it, either select Share printers connected to this system in the web interface, or manually set Browsing On in /etc/cups/cupsd.conf :
Note that «browsing» at the print server is a different thing from «browsing» at a remote networked host. On the print server, cupsd provides the DNS-SD protocol support which the avahi-daemon broadcasts. The cups-browsed service is unnecessary on the print server, unless also broadcasting the old CUPS protocol, or the print server is also «browsing» for other networked printers. On the remote networked host, the cups-browsed service is required to «browse» for network broadcasts of print services, and running cups-browsed will also automatically start cupsd .
The cups.service service will be automatically started when a USB printer is plugged in, however this may not be the case for other connection types. If cups.service is not running, avahi-daemon does not broadcast the print services, so in that case the systemd unit service file must be modified to start on boot, and then the service must again be «enabled/installed» with the new dependency. To do this, edit the service file [Install] section to add a WantedBy=default.target dependency, and then enable and start the cups.service service.
Sharing via Internet Printing Protocol
The server can be configured using either the web interface or by manually editing /etc/cups/cupsd.conf .
Open up the web interface to the server, select the Administration tab, look under the Server heading, and enable the «Share printers connected to this system» option. Save your change by clicking on the Change Settings button. The server will automatically restart.
On the server computer (the one directly connected to the printer), allow access to the server by modifying the location directive. For instance:
Also make sure the server is listening on the IP address the client will use:
There are more configuration possibilities, including automatic methods, which are described in detail in Using Network Printers and cupsd.conf(5) .
After making any modifications, restart cups.service .
If CUPS is started using socket activation, create a drop-in snippet for cups.socket so that socket activation also works for remote connections:
Sharing via Samba
Samba is an implementation of the Windows file and printer sharing protocols, even the most vintage ones.
To configure Samba on the Linux server, edit /etc/samba/smb.conf file to allow access to printers. File smb.conf can look something like this:
That should be enough to share the printer, yet adding an individual printer entry may be desirable:
Please note that this assumes configuration was made so that users must have a valid account to access the printer. To have a public printer, set guest ok to yes , and remove the valid users line. To add accounts, set up a regular GNU/Linux account and then set up a Samba password on the server. See Samba#User management.
After this, restart smb.service and nmb.service .
See Samba’s documentation Setting up Samba as a Print Server for more details.
Sharing via Line Printer Daemon protocol
Remote administration
Once the server is set up as described in #Printer sharing, it can also be configured so that it can be remotely administered. Add the allowed hosts to the block in /etc/cups/cupsd.conf , using the same syntax as described in #Sharing via Internet Printing Protocol. Note that three levels of access can be granted:
To give remote hosts access to one of these levels, add an Allow statement to that level’s section. An Allow statement can take one or more of the forms listed below:
Deny statements can also be used. For example, to give full access to all hosts on your local network interfaces, edit /etc/cups/cupsd.conf to include this:
You might also need to disable the HTTPS requirement, when using the default self-signed certificate generated by CUPS:
This should avoid the error: 426 — Upgrade Required when using the CUPS web interface from a remote machine.
Kerberos
Kerberos can be used to authenticate users accessing a remote CUPS server. This assumes that your machine has a keytab and it will need a ticket for «HTTP». Instead of using http://localhost:631 you must use https://host.example.co.uk:631 — encryption is required for auth (hence https) and the full hostname is needed so that Kerberos/Negotiate can work. In addition, the server must be configured in /etc/cups/cupsd.conf to use a DefaultAuthType of Negotiate .
If you are using Samba’s winbind NSS support, you can add an AD group name to /etc/cups/cups-files.conf — in the following example sysadmin might be an AD group:
Troubleshooting
See CUPS/Troubleshooting for general troubleshooting tips.
Cannot print with GTK applications
If you get a getting printer information failed message when you try to print from GTK applications, add this line to your /etc/hosts :
Permission errors on Windows
Some users fixed NT_STATUS_ACCESS_DENIED (Windows clients) errors by using a slightly different syntax:
Как расшарить принтер в ubuntu?
Как расшарить принтер в Linux?
Кстати, расшаривал принтер через микро-компьютер OrangePi – anonymous 4 года назад |
Спасибо! Помогло! – anonymous 4 года назад |
7 ответов
Чтобы расшарить принтер на linux, идём на следующий адрес с помощью любого браузера (порт 631):
Шаг1. Открыть общий доступ к принтеру в Ubuntu Linux (через IPP)
Дело в том, что в Linux печатью управляет служба CUPS. В Ubuntu, доступ к настройкам службы CUPS возможен через любой браузер на localhost по порту 631 — т.е. нужно открыть адрес «http://localhost:631«
Идём на адрес http://localhost:631/, открываем вкладку Администрирование, установить чекбокс Разрешить совместный доступ к принтерам, подключенным к этой системе
Компьютер с непосредственно подключенным (и уже расшаренным) принтером назовём «сервер«. Понадобится IP сервера, который можно узнать командой ifconfig
После установки чекбокса «Разрешить совместный доступ к принтерам, подключенным к этой системе» нужно подключить локальный принтер для всех «клиентов» — тех компьютеров, которые будут пользоваться принтером по сети.
Шаг 2. Подключение share-принтера на Linux-клиенте.
Если общий принтер на linux, то для подключения принтера на клиенте Linux скорее всего будет достаточно в настройках апплета «Печать» выбрать одно из: новый принтер, найти сетевой принтер, сетевой адрес и т.д., ввести ip сервера и нажать поиск. Принтер будет найден и подключен автоматически. Если вдруг по ip не удалось найти принтер, то проделать шаг 3 как для Windows-клиента.
Шаг 3. Подключение share-принтера на Windows-клиенте.
Для Linux тоже работает. Открываем в браузере настройки службы CUPS, указав ip сервера, например:
http://192.168.0.106:631/printers,
где 192.168.0.106 — ip-адрес нашей Linux машины c принтером.
Если компьютер виден в сети, то откроется страница со списком принтеров:
How To Share Printer On Network In Linux
Printing is an everyday job for us. Projects, office work, homework, etc. The basic fact is that we almost require printing every day. Now, what if we require sharing printer connected to our home Linux machine. So I decided to write a guide about it which is fairly simple. So, let’s start.
Add Your Printer To Computer
First basic thing is to install or add your printer. Connecting printer in Linux machine is very simple as almost all Linux distros have printer supports. Open the printer app from your app menu and look if the printer has been added.
If the printer is already added or configured, it will be listed quickly on the opening printer app. If not, go to Openprinting and install your driver and again launch your printer option. Your printer should now be listed under add option, click forward on your printer config. Add the description and done. Open printer driver page has a vast variety so it is very unlikely that you don’t find your printer.
Print anything to check your printer.Now as the printer is added let’s share it so you can access it on other systems. It is also simple. Right-click on your printer and select the shared option.
Here it is done. You have successfully shared your printer on a network in Linux. Now you will need to access it on other systems. Here is how to do it.
Accessing A Printer On Another Computer
I assume you are on LAN or somehow connected to your system from which we have shared our printer. Now here is what you have to do. Again open the printer tool as we did earlier and hit the ADD button. Your shared printer will be listed under the network printer. Click the remote hostname with the preferred printer, forward and fill out the description as we did earlier, apply and done. Voila! Print now!
If your printer is not listed, click on a find network printer. Enter the IP address of the printer and hit find. URI would be automatically filled. Again do as the old-time fill description and apply. Done!
Conclusion
Printing is nowadays very easy on Linux based distros. You can print anywhere using a network shared printer in your favorite distros. Drivers are also no more a problem nor the old-time configuring problems. Go print the world of your dreams(just kidding, print what you need, save papers, save trees :). Happy printing.