LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-11-2014, 04:50 AM   #1
call_krushna
Member
 
Registered: Aug 2007
Location: India
Distribution: Ubuntu
Posts: 173

Rep: Reputation: 1
Creating linux username and password remotely


I am running script which generated strong password and takes input as user name and calls remote script to create username and password .

script goes like this

USERNAME=$1

PASS=`cat /dev/urandom|tr -dc 'a-zA-Z0-9-!@#%()+{}$|:?='|fold -w 10 | head -n 1| grep -i '[!@#%()+{}|:$?=]'`

ssh -i /home/ubuntu/test.pem ubuntu@192.168.10.32 "sudo /bin/bash /root/useradd.sh $USER $PASS "

It works fine ,if the password does not contain any extra characte like | , & and $ .

e.g.

ssh -i /home/ubuntu/test.pem ubuntu@192.168.10.32 "sudo /bin/bash /root/useradd.sh testuser1 12345 "

it fails with strong password as follows .

ssh -i /home/ubuntu/test.pem ubuntu@192.168.10.32 "sudo /bin/bash /root/useradd.sh testuser1 v|9q4TT8={ "

Is there any workaround for this .
 
Old 04-11-2014, 05:36 AM   #2
Smokey_justme
Member
 
Registered: Oct 2009
Distribution: Slackware
Posts: 534

Rep: Reputation: 203Reputation: 203Reputation: 203
Code:
ssh -i /home/ubuntu/test.pem ubuntu@192.168.10.32 "sudo /bin/bash /root/useradd.sh '${USER}' '${PASS}' "
should do the trick
 
Old 04-11-2014, 06:36 AM   #3
call_krushna
Member
 
Registered: Aug 2007
Location: India
Distribution: Ubuntu
Posts: 173

Original Poster
Rep: Reputation: 1
Thanks for the information . It is not working for password like OvmE1c(IXq .

my useradd.sh script contains following lines .

set -x
USER=$1
PASS=$2
useradd -M -s /bin/nologin $USER
echo $USER:$PASS | chpasswd

Regards
Krushna
 
Old 04-11-2014, 08:24 AM   #4
Smokey_justme
Member
 
Registered: Oct 2009
Distribution: Slackware
Posts: 534

Rep: Reputation: 203Reputation: 203Reputation: 203
Hmm.. passwords like "OvmE1c(IXq" should work.. I've got nothing of the top of my head..

Try to change your script like this:
Code:
USER="${1}"
PASS="${2}"
useradd -M -s /bin/nologin ${USER}
echo ${USER}:${PASS} | chpasswd
P.S. Always probe that simple passwords still work.. Just to be sure a change didn't brake anything..
 
1 members found this post helpful.
  


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
[SOLVED] just installed mysql srver 5.1, but getting errors while creating username&password. imran042 Linux - Newbie 20 03-03-2012 12:27 PM
puppy linux 4.1.2 username/password tigertim71 Puppy 3 04-20-2009 03:45 PM
linux username and password? doğa Linux - Software 5 09-24-2008 01:46 PM
Creating username and password authenticated network connection Bionics Linux - Networking 4 02-08-2008 12:43 PM
Linux Username and password only ASCII? LogicMagic Linux - Newbie 5 02-26-2004 03:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:51 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