LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 02-04-2016, 10:40 PM   #1
emacsx
LQ Newbie
 
Registered: Feb 2016
Posts: 11

Rep: Reputation: Disabled
Question Adding multiple users and setting vnc passwords?


I can add users using the following commands without specifying a group
# useradd USER1
# passwd USER1
password: ******
Retype password:
password: ******

but if I use the following script with a text file (user_list.txt) containing list of user, i.e. one user per line and user name and password separated by a space, will that work? Am I missing something in the script?

=======================
#!/bin/bash
NEW_USERS="/tmp/scripts/user_list.txt"
HOME_BASE="/home/"

cat ${NEW_USERS} | \
while read USER PASSWORD
do
useradd -p ${PASSWORD} -m -d ${HOME_BASE}${USER} ${USER}
done
=======================

user_list.txt content:
=======================
USER1 USER1_PASSWORD
USER2 USER2_PASSWORD
USER3 USER3_PASSWORD
...
USER9 USER9_PASSWORD
=======================

For the same users I have to set the vnc password for each user manually using the following commands.
# su - USER1
$ vncpasswd
password: ******
Retype password: ******
$ exit

How can I write a script to read the same text file and set vnc passwords?
BTW I am using Red Hat Linux 5.

Last edited by emacsx; 02-05-2016 at 02:29 AM.
 
Old 02-05-2016, 07:02 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
If you have many users, etc. to maintain, and especially if you have many systems upon which to maintain them, it quickly becomes advantageous to use a central authority, such as LDAP (a.k.a. Microsoft OpenDirectory) to do the job. Instead of attempting to update cumbersome per-system password files, have each machine consult the central authority to validate passwords.

If you have a mixture of Microsoft, OS/X, and Linux systems, the good news is that all of these can simultaneously use the same authority, allowing "single sign-on" if you so desire.
 
Old 02-06-2016, 11:37 PM   #3
emacsx
LQ Newbie
 
Registered: Feb 2016
Posts: 11

Original Poster
Rep: Reputation: Disabled
Question How to write a script for setting vnc passwords for multiple users?

I managed to get the user add script work, but how to write the following commands in a script for setting vnc password for multiple users? I need to read a text file (user_list.txt) containing list of user, i.e. one user per line and user name and password separated by a space.

# su - USER1
$ vncpasswd
password: ******
Retype password: ******
$ exit

user_list.txt content:
=======================
USER1 USER1_PASSWORD
USER2 USER2_PASSWORD
USER3 USER3_PASSWORD
...
USER9 USER9_PASSWORD
=======================
 
Old 02-07-2016, 12:34 AM   #4
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
If you cannot find some 'add_many_users' commands, you have to do it with expect. It won't be very easy though. Google might help.
 
  


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
adding users and passwords from a .txt file help feebleskull81 Linux - Newbie 3 07-10-2014 08:04 PM
adding users and passwords with adduser sean04 Programming 3 03-12-2012 03:11 AM
Creating groups, users, setting passwords gtrrockz84 Linux - Networking 1 01-06-2012 06:39 AM
Automate adding users and passwords linuxy2 Linux - Security 1 03-03-2007 01:32 AM
adding users and passwords to mysql caged Programming 1 10-27-2004 05:22 PM

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

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