- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script to find and delete a user account from mult...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-20-2011 02:02 AM
тАО09-20-2011 02:02 AM
Hi all,
Some times i am in need of logging in multiple servers and to find out for some useraccounts to delete it.Is there any script available to do it with out logging in all the servers.SUDO access with out asking password is permitted in my useraccount.
User id & password is same for all systems.
Give me some solutions
Prakash
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-20-2011 02:06 AM
тАО09-20-2011 02:06 AM
Re: Script to find and delete a user account from multiple HP-UX servers
If you have NIS or LDAP, you could manage your users centrally.
Otherwise you could use ssh to run scripts on each machine.
Do you shared /home or other directories on all machines?
- Tags:
- ssh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-20-2011 03:04 AM
тАО09-20-2011 03:04 AM
Re: Script to find and delete a user account from multiple HP-UX servers
HI dennis,
We don't have NIS or LDAP .No shared directories on all machines.
Is there any other way ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-20-2011 04:36 AM
тАО09-20-2011 04:36 AM
Re: Script to find and delete a user account from multiple HP-UX servers
Hi:
You could setup SSH public keys and once done, use 'ssh' to remotely manage your accounts.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-21-2011 08:42 AM
тАО09-21-2011 08:42 AM
Re: Script to find and delete a user account from multiple HP-UX servers
Hey;
>>Some times i am in need of logging in multiple servers and to find out for some useraccounts to delete it.Is there any script available to do it with out logging in all the servers.
Without a centralized user management system such as LDAP or NIS, you obvioulsy *have* to log into each machine in order to manage the accounts because that's where they're defined.
There are no predefined scripts as far as I know. However, the psuedo code algorithm for what you're looking for is relatively easy:
for host in ${list-o-hosts}
do
useradd/del ${user} on ${host}
done
Now, the trick is to figure out a good way to access the hosts. Someone already mentioned ssh using public key authentication (pka). That is hands down the best way available without spending money. You can also write perl/expect scripts to automate password authentication using either telnet or ssh.
I advocate using ssh/pka to directly access root and other sensitive accounts as it's more secure for a variety of reasons. A white paper outlining those reasons is available but is off topic. Search these forums for it or send me an email and I'll get the url to you.
So, assuming ssh/pka access to root:
user=$1
for h in $(cat hosts)
do
echo ${h}
ssh ${h} "grep ^${user}: /etc/passwd 2>/dev/null" | \
grep -q ${user} && ssh -n -x -l root ${h} userdel -r ${user}
done
There are plenty of other things you could do - find all the user's files, back up home directory, send emails, etc, etc; however, that loop will get you the gist of what you were looking for.
Doug
------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-22-2011 07:59 AM
тАО09-22-2011 07:59 AM
Re: Script to find and delete a user account from multiple HP-UX servers
Will use and confirm as soon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-03-2011 11:35 PM
тАО10-03-2011 11:35 PM
Re: Script to find and delete a user account from multiple HP-UX servers
If i want to delete multiple users from multiple servers on a regular basis like monthly.
what would be the solution?
can you a provide a script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-04-2011 02:10 AM
тАО10-04-2011 02:10 AM
Solution>If I want to delete multiple users from multiple servers on a regular basis like monthly.
Doug provided a script to delete one user. You just put that in a loop to handle multiple users on the command line:
for user in $*; do
for h in $(< hosts); do
echo ${h}
ssh ${h} "grep ^${user}: /etc/passwd 2>/dev/null" | \
grep -q ${user} && ssh -n -x -l root ${h} userdel -r ${user}
done
done