Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 12-12-2015, 06:28 AM   #1
LQ Newbie
Registered: Dec 2015
Posts: 1

Rep: Reputation: Disabled
ssh and adding users in multiple users

In our environment i have to ssh to each an every servers
ssh <hostname> then which prompts for password for every login
i have to create a user name on 30 severs manually it takes much time so need a script to do this task i have googled and found some for loop scripts but it did not fullfill the requirement.
First i have to check whether the users exists and not and later add the user or reset the password for user using script
Old 12-12-2015, 09:26 AM   #2
Senior Member
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora, Alpine, Cirros, OpenSuse/SLES
Posts: 3,444

Rep: Reputation: 902Reputation: 902Reputation: 902Reputation: 902Reputation: 902Reputation: 902Reputation: 902Reputation: 902
The command to create a new account is useradd.
No need to check if the user exists already; useradd will do that for you and exit with an exit value of 4 if that is the case (see man page).

useradd also has options to set the password and parts of the password policy, e.g. the -p option. Otherwise, you can for example use passwd --stdin to provide the password from standard input.
Old 12-12-2015, 01:49 PM   #3
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,842

Rep: Reputation: 1472Reputation: 1472Reputation: 1472Reputation: 1472Reputation: 1472Reputation: 1472Reputation: 1472Reputation: 1472Reputation: 1472Reputation: 1472
30 servers?

It is time to use LDAP and Kerberos instead.
1 members found this post helpful.
Old 12-12-2015, 08:46 PM   #4
Registered: May 2011
Location: TX
Distribution: Debian
Posts: 762

Rep: Reputation: 220Reputation: 220Reputation: 220
+1 vote for LDAP


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
shell script for adding multiple users on multiple servers. newtech Linux - Newbie 3 04-07-2015 03:58 AM
ssh and adding users in multiple users James0806 Linux - Newbie 1 02-04-2015 01:51 PM
[SOLVED] Adding users to multiple groups in Openldap skimeer Linux - Newbie 1 09-03-2012 01:36 AM
Bash script for adding users is running but not adding users Gren Programming 2 04-27-2012 03:53 AM
bash script for adding multiple users pilipk01 Linux - Newbie 4 01-12-2004 10:05 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:33 PM.

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