LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-01-2017, 11:30 AM   #1
blason
Member
 
Registered: Feb 2016
Posts: 122

Rep: Reputation: Disabled
Just a weird idea with bash scripting


Hi Guys,

Would it be possible to restrict the daemon access using certain strings just like key generator? Like you know I can generate SHA1 string and unless and until that string is passed certain services will not start. I mean just like serial key for software but not exactly as such serial key but wanted to restirct access of services.

Can we do that or does anyone have any better idea than this? Let say I want DNS should not be started unless and until the SHA1 string is entered which is of only one time initially as well as can I keep the access for certain days and daemon will automatically stop.

Like say for 365 days and if the new SHA1 key is not entered daemon will stop automatically after 365 days.

Seems to be weird, huh
 
Old 03-01-2017, 11:34 AM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
You can configure sudo/sudoers to allow certain users to run certain commands like 'systemctl start bind'. And you can require sudo to require a password when running the commands. So -- change the user password to this sha1 sum and you have what you are describing.

Not sure what the difference between a SHA1 sum and a complex password is.

Last edited by szboardstretcher; 03-01-2017 at 11:35 AM.
 
Old 03-01-2017, 11:39 AM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,308
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
You might further refine that suggestion by using a one-time password setup and then doling out the passwords one at a time.
 
Old 03-01-2017, 11:40 AM   #4
NoStressHQ
Member
 
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609

Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by szboardstretcher View Post
Not sure what the difference between a SHA1 sum and a complex password is.
An obvious one is that any hash can't be attacked by a dictionary attack.

But what the OP seems to talk about is some kind of restricted, time-limited access control (whether it is for security or paid-service reason).

Your sudoer "hack" can do the trick, or at least be a temporary workaround.

Cheers.
 
Old 03-01-2017, 11:46 AM   #5
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Quote:
An obvious one is that any hash can't be attacked by a dictionary attack.
Neither can a 'complex' password.

SHA1sum - 68cd0415d0917a830166e4802fb6a581f418f4a8
Complex Password - 2%5pbc94vkCB5J5G94QLBGM2#AXc$8EZB3@x0(nj

OP: Why SHA1?
 
Old 03-01-2017, 12:05 PM   #6
NoStressHQ
Member
 
Registered: Apr 2010
Location: Geneva - Switzerland ( Bordeaux - France / Montreal - QC - Canada)
Distribution: Slackware 14.2 - 32/64bit
Posts: 609

Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by szboardstretcher View Post
Neither can a 'complex' password.
Well I didn't know that "complex password" had an official specification of being randomly generated, although "random password" can be classified within "complex password" group.

Anyway, the OP problems sounds to me like a "commercial licensing" key for customers. SHA1 or "whatever" could do the job, maybe because he already have this kind of key, but it's a detail.

Problem with what he asks is, there are a lot of chance that it will require a specialized daemon to check the key on one side, and being able to kill the "secure service" once the date is over... But anyway it sounds like a solution full of security holes which is the main problem (depending on the "criticalness" of the subject of course).
 
Old 03-01-2017, 12:24 PM   #7
blason
Member
 
Registered: Feb 2016
Posts: 122

Original Poster
Rep: Reputation: Disabled
Well kinda of security key but I dont mind that is hackable or can be cracked but for at least something you know for show off reason a key is entered and then only a daemon has started. The basic idea is I can generate a file which has person name, address and duration and that file then passed through SHA1 sum which can be used to start the daemon once? Further to that probably restricting access if it does not work its OK. I can manually keep a track of it.
 
Old 03-01-2017, 03:48 PM   #8
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
And what does bash have to do with this licening problem?
 
1 members found this post helpful.
Old 03-01-2017, 04:19 PM   #9
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
I have read this thread several times and am not really any closer to understanding the point of your question. It would be helpful (if only for myself) if you could provide a better, more complete description of your overall objective.

Specifically, you have focused on doing this with a bash script, but there is no obvious reason for that.

You also say it is "kinda of security key" (aka license key), but you need to provide a more complete description of how it will be deployed and used for us to understand why it is only "kinda" and not "really" a license key - you are quite vague on that point.

Is this code to be used only on your own system? If so the sudo approach might apply. If not, then how is the script/key to be distributed to others, what daemons it would affect and in what context is it to be run by those others on their own systems?

A more complete description of your actual intended use case would go a long way toward clearing up these questions.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Shell Scripting Part I: Getting started with bash scripting LXer Syndicated Linux News 0 04-29-2015 08:03 AM
Bash Scripting – Code Structure - Defining Multiple Points Of Entry In Bash Script carlr Programming 10 08-25-2014 02:38 AM
[To share Bash knowledge]Notes for Advanced Bash-Scripting Version 10 (Latest) jcky Programming 4 07-31-2014 09:24 AM
LINUX GURUS..any idea on scripting for a right click .. neo2k Linux - Newbie 5 03-13-2009 03:15 PM
Weird touchpad feature no idea how to disable SickNick Ubuntu 2 11-29-2007 12:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration