![]() | Register | FAQ | Members | Social Groups | User Map | Calendar | Search | Today's Posts | Mark Forums Read |
*nix
*nix forum sponsored by |
| ||
| | | LinkBack | Thread Tools | Search Thread |
| Sponsored Links |
| | #1 |
![]() Join Date: Aug 2005 Location: London
Posts: 2,259
Thanks: 46
Thanked 315 Times in 278 Posts
Blog Entries: 1 Rep Power: 72 | In Windows I'd do something like: Code: for %i in (1 2 3 4) do psexec \\computer%i <some command> I know I can use SSH to remotely execute a command but it prompts for a password every time (and if I've not connected to the machine before I also get asked to accept the key). I'd like to do this without having to type the password lots of times or I might as well just go and log on to 36 machines! |
| |
| | #2 | |
![]() Join Date: Aug 2005 Location: Alton, Hampshire
Posts: 2,779
Thanks: 416
Thanked 315 Times in 265 Posts
Rep Power: 83 | Quote:
ssh -o stricthostkeychecking=no -i my.key root@SERVERNAME commandGoesHere The stricthostkeychecking=no bit will skip you being asked whether you wish to accept the remote signature key. You might have to delete the local .ssh/known_hosts beforehand. -- David Hicks | |
| |
| Thanks to dhicks from: | srochford (27-04-2009)
|
| | #3 |
![]() | Not an elegant (or secure!) solution but you can use EXPECT in scripting to respond to interactive prompts if necessary. expect(1) - Linux man page SSH login expect shell script to supply username and password Code: #!/usr/bin/expect -f
# This script needs three argument to(s) connect to remote server:
# password = Password of remote UNIX server, for root user.
# ipaddr = IP Addreess of remote UNIX server, no hostname
# scriptname = Path to remote script which will execute on remote server
# For example:
# ./sshlogin.exp password 192.168.1.11 who
# set Variables
set password [lrange $argv 0 0]
set ipaddr [lrange $argv 1 1]
set scriptname [lrange $argv 2 2]
set arg1 [lrange $argv 3 3]
set timeout -1
# now connect to remote UNIX box (ipaddr) with given script to execute
spawn ssh -p 22 root@$ipaddr $scriptname $arg1
match_max 100000
expect {
-re ".*Are.*.*yes.*no.*" {
send "yes\r"
exp_continue
#look for the password prompt
}
"password:" {
send -- "$password\r"
#he expect command will now return
}
}
Last edited by somabc; 23-04-2009 at 05:14 PM.. |
| |
| | #4 |
![]() Join Date: Dec 2005 Location: In the server room, with the lead pipe.
Posts: 1,922
Thanks: 108
Thanked 174 Times in 129 Posts
Rep Power: 53 | You didn't mention whether you were querying for info or making changes, but if it's the latter you could also look at using puppet to automate things. Make a change to the reference file on the puppetmaster server and the puppets will all pull in the change when they next check in with it. Start with something simple and small (adding the school name to /etc/motd, for example) and move on from there. puppet - Trac Redmonk episode that led to me implementing it here: People Over Process » Puppet at Google - RedMonk Radio Episode 48 |
| |
| | #5 | |
![]() | There is also sshpass, but again with the need to hardcode passwords Key based login is really the way to go! sshpass: Login To SSH Server / Provide SSH Password Using A Shell Script Quote:
| |
| |
| | #6 |
![]() | This is EXACTLY what you want! ClusterSSH controls a number of xterm windows via a single graphical console window to allow commands to be interactively run on multiple servers over an ssh connection. SourceForge.net: Cluster SSH - Cluster Admin Via SSH ssh on multiple servers Using cluster ssh -- Debian Admin ClusterSSH - Cluster Wiki |
| |
| Thanks to somabc from: | srochford (27-04-2009)
|
| | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Having Macs And Windows Computers Running On The Same Netwrok (Windows 2003) How do.. | Antp | Mac | 34 | 30-10-2008 04:52 PM |
| PHP commands | Silverman | Web Development | 10 | 03-06-2008 03:24 PM |
| Computers for Schools Scheme, anyone running this yet? | markman | General Chat | 19 | 09-01-2008 06:28 PM |
| Running batch files in vista | Kained | Windows Vista | 6 | 04-09-2007 02:25 PM |
| Running local commands remotely | MK-2 | Windows | 6 | 02-03-2007 11:31 AM |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search Thread |
| |









