nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

ssh many hosts , su - using different passwords

This is a discussion on ssh many hosts , su - using different passwords within the Shell scripting forums, part of the Development/Scripting category; Hi, I would like to do ssh to many hosts and then would like to do su - with respective ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 09-20-2007, 11:13 PM
Junior Member
User
 
Join Date: Sep 2007
My distro: Sun Solaris/Linux
Posts: 7
Rep Power: 0
newbewie is on a distinguished road
Default ssh many hosts , su - using different passwords

Hi,
I would like to do ssh to many hosts and then would like to do su - with respective host's passwords and execute certain commands.

This being a secure and big network , we have to login every server individually and then su with different passwords.

So is there a way to achive it?

Thanks a lot in adance
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-24-2007, 09:00 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Yes you can do that but you need to explain the same in more details. There a few automated tool exists that can do the job but givme out more info
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #3 (permalink)  
Old 09-24-2007, 09:07 PM
Junior Member
User
 
Join Date: Sep 2007
My distro: Sun Solaris/Linux
Posts: 7
Rep Power: 0
newbewie is on a distinguished road
Default

Glad to see a response.

This is the scenerio:

Hostname : host1, host2, host3

(Username has same password on all the server
Username: user
Password for user: password

Different host has different root passwords
Host:host1 - root password host1
Host:host2 - root password host2

so it would be like

ssh -l <user> host1
after giving password
su -
<root password>
command
command
exit

Will this make any sense?

Thanks again
Reply With Quote
  #4 (permalink)  
Old 09-25-2007, 06:50 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,036
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

There are two ways..
a) Store actual password in text file (which is bit risky if someone got access to file, you are doomed)
b) Use ssh keys for automation and login - which what I recommend
c) Write a daemon / service and work in client / server environment to control all server. Requires network programming using perl / php /c /c++ etc. Difficult to maintain

Solution b is easy to use and implement:
First generate ssh key and upload to all your servers
Don't use su, use sudo w/o password to run commands
Write script to connect such as
Code:
#!/bin/bash
# some init
ssh -l username server1.com
sudo /path/to/command1
sudo /path/to/command2
# and you are done!
Run above script for all server or just add for loop and read all server names form an array.

Hope this helps!
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Adding Users in Bulk + Passwords and permissions ricksd2sd Shell scripting 0 04-23-2008 01:20 PM
how to reset root and user passwords - new install forlornhope Linux software 2 07-05-2007 01:51 AM
Linux prevent the reuse of old passwords chimu Linux software 3 05-14-2007 06:49 PM
/etc/hosts file ricc Linux software 1 05-08-2007 08:32 PM
Problem changing expired passwords via ssh session tom Linux software 1 07-24-2006 12:42 AM


All times are GMT +5.5. The time now is 07:43 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36