Saturday, April 25, 2020

oDroid C2 CUPS Print Server - Samsung SCX - Ubuntu 18.04 Minimal

Since we're stuck working from home, my wife and I are getting more serious about our "home office" layouts.  One thing I'd had on my "to do" list for awhile was configuring up some non-network printers to be shared via the network.  While some of this was easily solved by simply having them near another computer (impossible not to be near a computer in MY office), for other areas another solution was needed.

I had some Raspberry Pi 3b's and oDroid C2's left over from a project awhile back, so I flipped a mental coin, picked up the board that was marginally closer to me and went about setting up a print server on the oDroid C2.  However, there are similar configurations of course for the RPi.

As a "sorta Linux guy" in that I install/configure it occasionally for a specific use-case, but as a "Windows guy" for my normal day-to-day, I found this both simple and annoying.

Step 1)  Get Ubuntu 18.04 Minimal

I use the "Minimal" installs wherever possible when I'm doing embedded projects for purpose-built builds.  I don't want the extra goodies and GUI.  I'll add only what I need.

The oDroid wiki has links for all the relevant images for the C2 (and others).  Pick one close to you and download it.

Step 2) Get your image onto an SD card

I've used a few different methods over the years to create SD cards from images.  I use Windows 10 regularly on my desktop to do this.  Currently, I've been using belenaEtcher.  You can get it here.

I also have been using SanDiskUltra microSDHC UHS-I cards for most of my projects as well.  You don't get the full speed benefits from it on the oDroid's, but it's better than average otherwise.
Good enough
You can probably do just fine w/ an 8GB card, I just happen to have a stack of 16GB's (and a slightly smaller stack of 64GB's) so I grabbed one.

Unzip the image using 7zip or similar.  Open belenaEtcher.  Select the image you extracted.  Write it to your SD card.  

Step 3) Update your image & configure your server name

Install the SD card into your C2, connect it up to your network, add a keyboard, and power it up.  You likely will need to connect this to a monitor (I do this out of habit now) at first boot as often times images now disable SSH by default until security is configured.

Just because you downloaded the "latest image" doesn't mean it is up to date.  So log in:
  • Login: root
  • Password: odroid
Then run the following commands to update your install:
  • sudo apt update
  • sudo apt upgrade
Answer Y where applicable and you'll update your box to the latest version of the release you are working with.

You also should change your box's name before deploying it.  By default, all of the oDroid board images have a default name of "odroid".  Which is fine.  For one board.  Then it gets confusing.  So do the following:
  • sudo nano /etc/hostname
    • change odroid to be (your system's new name)
    • save/exit
  • sudo nano /etc/hosts
    • change odroid to be (your system's new name)
    • save/exit
If necessary you can reboot your box at this point just to be 100% certain it was renamed.
  • sudo reboot 0

Step 4) User Setup

This section might be slightly different depending upon your preferences.  However, this basically is disabling the root user and creating a new "admin" level user.

For basic USER setup, here's essentially the list of commands to run through.

Get started adding a new admin user and removing root.  Just copy/paste the following commands and change the italics items to reflect your user
  • useradd -m -c "Some User" someuser
  • passwd someuser
    • enter your new password
  • usermod -aG sudo someuser
  • sudo mkdir /home/someuser/.ssh/
    • (this is optional, but if you use ssh keys for other Linux boxes then you should start this as a good habit)
  • scp someuser@someOtherLinuxBox:/home/someuser/.ssh/authorized_keys /home/someuser/.ssh/authorized_keys
    • (optional, but recommended - this is copying your authorized_keys file from another box you've previously configured)
  • su someuser
    • Now you're logged in as the new user 
  • sudo passwd root
    • change the root password
  • sudo nano /etc/passwd
    • change the "root:x..." line to:
      • root:x:0:0:root:/root:/sbin/nologin
    • save/exit
  • sudo nano /etc/ssh/sshd_config
    • change the "PermitRoolLogin..." line to:
      • PermitRootLogin no
    • save/exit
  • sudo systemctl restart sshd
At this point, your new user should be able to log in via your new user/pwd (and potentially w/o a password if you're using keys), but not w/ root.

As well, if SSH is enabled on your box, then that also should be similarly configured.

Step 5) Print Server (CUPS) setup

Now, if you go searching the internet on CUPS, you may well get outdated info.  Cups.org is where the latest details are.  Go there.  Now.  Why are you still here?  Well, if this is out of date then that's on you.  ;)

The steps below are designed to allow your print server to be a headless remotely manageable box that you can just plug in behind a printer somewhere and forget about (until your home gets hacked because you forgot to set up auto updates).
  • sudo apt install cups
  • sudo cp /etc/cups/cupsd.conf /etc/cups/cupsd.conf.original
    • just making a backup of the configuration file
  • sudo usermod -aG lpadmin someuser
  • cupsctl --share-printers
    • starts printer sharing
  • cupsctl --remote-admin --remote-any --share-printers
    • allows you to be able to access the admin portal from other machines
  • sudo systemctl restart cups.service
    • restarts the service
At this point, the service is configured and running.

(OPTIONAL) Step 6) Samsung driver package

For my scenario, I was using an old Samsung SCX laser/scanner/copier that my parents "broke" and I replaced/changed-the-ink-in/brought home.

The Samsung printers use some screwy drivers so there is a project set up to allow Samsung printers to work better w/ Linux: Splix.

If you're using a Samsung printer, then also do the following:
  • sudo apt install printer-driver-splix
  • sudo systemctl restart cups.service
That's it.

Step 7) Add your printer

Now the box is actually running and is acting as a print server.  It isn't connected to any printers, but now's the time to plug something in.  For me, I was connecting the C2 to a USB port on the back of my Samsung SCX 4623.  

Move the C2 to the printer and plug everything in.  You should now be able to access the C2 remotely via the web admin using the following from your browser on another PC:
  • https://(your system's new name):631/admin
This should get you here:
CUPS Web Admin
You might get a warning here from your browser as this isn't an HTTPS connection.  If necessary, just click through to force this through to the page.

Now you can add your printer by clicking on [Add Printer] on the above page.

This should show a list of printers that are seen.  Most of these are just ports and software functions, but hopefully...HOPEFULLY...you'll see the printer you plugged in.  Add it, set up the ancillary settings and you're done.

Mostly.

But you still need to print to this thing.

Step 8) Set up your Windows 10 clients

Supposedly, if you're not using some screwy Samsung printer, then you should be able to just add a Printer in Windows 10.  However, in this case, there were a few extra hoops.

Add the Printer and it should detect the network printer (you'll feel very good at this point - it won't last).  Windows will add the "printer" which it now will forget is a printer.
Uhhh..it's a printer
You can't just tell Windows this is a printer though (apparently) you now have to add it AGAIN.  Now, this worked 2 different ways for us.  

On one box,it worked to just copy the URL from the printer page in the CUPS Web Admin and add it here:
However, for another box, this didn't work.  I had to go into the "Unspecified" Samsung printer icon, right-click, select Properties, then go to the Connected Device tab, and copy the "Unique identifier" value and then use that instead in the above box.


No comments:

Post a Comment