LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 07-18-2014, 02:37 AM   #1
kjsubbu
Member
 
Registered: Apr 2003
Location: india
Posts: 73

Rep: Reputation: 15
Automatic User Creation with SSH Key creation


Hi Friends,
i am trying to find out anyone is having scripts to create the users with ssh keys for password less login
i like to get to automate the user creation on my production servers..
if any one is having please share with me..
 
Old 07-18-2014, 07:38 AM   #2
MCD555
Member
 
Registered: May 2009
Location: Milan, Italy
Distribution: Ubuntu, Debian, Fedora, Oracle Linux
Posts: 109

Rep: Reputation: 10
Hi Kjsubbu,

you mean, you would like to:

- create a new user on your server
- automatically add the public key of that user (in the /home/[username]/.ssh/authorized_keys) to permit key authentication

Do you?
It shouldn't be difficult to do with a simple script (bash, perl or something else)...

Last edited by MCD555; 07-18-2014 at 07:39 AM. Reason: misstyping
 
Old 07-18-2014, 08:29 AM   #3
kjsubbu
Member
 
Registered: Apr 2003
Location: india
Posts: 73

Original Poster
Rep: Reputation: 15
Hi MCD555

thanks for your help.. if you are having any scripts can you please pass to me..
 
Old 07-18-2014, 11:23 AM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
http://goo.gl/MuBalt
 
Old 07-20-2014, 04:45 AM   #5
Turbocapitalist
Senior Member
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 4,885
Blog Entries: 3

Rep: Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439Reputation: 2439
/usr/local/sbin/adduser.local

In some distros, you can add your custom script in /usr/local/sbin/adduser.local It will then be launched by adduser after the account is created. You can use that to copy or create your keys. See the manual page for adduser on your system to see if that file is relevant.
 
Old 07-21-2014, 09:15 AM   #6
MCD555
Member
 
Registered: May 2009
Location: Milan, Italy
Distribution: Ubuntu, Debian, Fedora, Oracle Linux
Posts: 109

Rep: Reputation: 10
To start, try to get a look at this:

opt #1 http://www.linuxnix.com/2011/08/crea...ers-linux.html
opt #2 http://www.tuxradar.com/answers/492

where you can find some simple scripts to add user(s) with a batch procedure.
Further, you can simply add a couple of lines to add, for each user, their own public key.
I mean something like this:

And in the loop:

Quote:
..
# Add user authorized key
mkdir /home/[user_home_dir]/.ssh
chmod 744 /home/[user_home_dir]/.ssh
cat [path_to_user_publickey] >> /home/[user_home_dir]/.ssh/authorized_keys
...
But please note:

- you already have a copy of the user public key (in order to authorize it)
- you have to verify the naming and position of authorized keys onn your system (you can get this from your /etc/ssh/sshd/config --> line AuthorizedKeysFile

Last edited by MCD555; 07-21-2014 at 09:37 AM. Reason: just get out redundancy ...
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
SFTP user creation without SSH jithinsha Linux - Newbie 7 05-31-2013 05:51 AM
System user creation with mysql user creation moos3 Programming 1 08-11-2007 08:01 PM
Automatic AD user directory creation/mapping HalJordan Fedora 5 02-19-2005 10:31 AM
automatic user account creation in mail server kar11 Linux - Software 0 04-13-2004 11:55 PM
Automatic user creation Skorpio Linux - Networking 3 09-25-2003 10:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 05:17 AM.

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