Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Here's a bit of background which you can skip unless you want to know why I created this workaround:
There is a printer on the network in the building of my office which does not allow printing through its http interface unless you are physically connected to the network. While in my office, I generally connect to the building's routers with my laptop, as my desk is quite far from the Ethernet socket. At any rate, the printer does not consider the building's router to be a part of the network. I do have an account on a server connected to the printer which I can SSH into. So I have created a bit of a workaround (described below) which allows me to print somewhat seamlessly through CUPS. It is quite an ugly solution but I am mostly curious without potential security issues I have opened up. Of course if anyone has suggestions to make it less ugly, I certainly wouldn't turn them down.
Anyway, here's my most-likely-insecure workaround:
I created a CUPS backend which is really a script whose main function is to run
Where $USER is of course my username on $SERVER, and $ID_RSA is a password-less ssh-key which can only be used by root which I specifically creaated for this workaround. (Note that in a CUPS backend, $6 is the location of a ps file with CUPS creates to be printed)
The corresponding entry to the ssh-key in the authorized_keys file on the server starts with
command="lp -" ssh-rsa ...
So that using the specific $ID_RSA (to my best understanding) will only try to print the file I supply and then close the connection.
The sudo command is allowed by the sudoers file as such:
where of course the variables are the actual ones I would use. The point is only this one very specific command cay be used by users in lp without a password. Furthermore, no users are in the lp group except root (and the CUPS daemon runs as user "daemon" in group lp, so it can sudo this command without a password).
I am sure there are many security holes in this, but I don't know enough to point them out. So I am turning to those with more experience. Thanks for taking the time to read this!
Thanks,
Ryan
Click here to see the post LQ members have rated as the most helpful post in this thread.
Distribution: Ubuntu, OpenSUSE, Mythbuntu, Embedded Linux
Posts: 46
Rep:
Seeing your already got an account on that side of the network,
why not simple set up a http tunnel. Once your set it up. the arrangements
to talk to it will be not messy at all, and it will do the job your
trying to complete.
I am away from my Linux library currently so I can't give you a step
by step break down on setting such a beast up, but most good Linux ssh/ssl
books have all the information you will be needing to get set up and running.
password-less keys are not a good idea if the client computer is mobile. Someone finding it, stealing it or gaining access to the computer wouldn't have to guess the passphrase unlocking your private key.
The passphrase is only used at the client, to unlock the private key. You can use ssh-agent and ssh-add to enter the passphrase once. This can be integrated with your distro's keychain, where you enter the passphrase once when you log in, and then you don't need to enter it again.
To use ssh-agent and ssh-add manually from the shell:
eval $(ssh-agent)
ssh-add
Your method of using a command in authorized_keys is used to allow certain users to launch backup jobs and nothing else. Perhaps for updates just posted to a website. The advantage is that they don't get shell access. It is possible to launch an ssh command to do that, but a script on the client side could be modified by the remote use, who might not be trusted.
WildPossum: I will look into the http tunnel, this might be a good solution. The only thing I fear about this is opening up the printer to everyone, but this might be because I am misunderstanding the concept.
jschiwal: I agree password-less keys are a bad idea. When I tend to think of security risks I suppose I forget about physical security risks. Similarly, I forget that the problem could be that someone changes the actual scripts (I am always more worried what someone can do even if everything goes right). Thanks for bringing these to my attention. Perhaps ssh-agent is the right way to go.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.