Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ssh via rsh and feed of local file via cat command 1

Status
Not open for further replies.

babcia01

IS-IT--Management
Jul 11, 2002
37
0
0
US
Hi
Would anyone know how to accomplish via remote ssh same capabilities as can be accomplished via rsh command as noted under 1)?

The 1-st rsh based command works. The local filex is read into rsh chpasswd command on the remote server.

1) cat filex| rsh serverx chpasswd

The below 2-nd command does not work. I want to eliminate placing filex on each remote server where I want to run the chpasswd due to its sensitive nature even though I will delete it after I am done.

2) cat filex |/usr/local/bin/ssh -n -q -o "StrictHostKeyChecking no" -o "BatchMode yes" root@serverx chpasswd
 
Nice Question babcia01

What is the error you get when you run command no 2?

Regards,
Khalid
 
dziadek here babcia:

root@ganzegal /
# grep -p ^ble: /etc/security/passwd
ble:
password = gdDHzWhpT2r46
lastupdate = 1175851726
flags =

root@ganzegal /
# echo ble:ble2|ssh ganzegal 'cat|chpasswd'
root@ganzegal's password:
root@ganzegal /
# grep -p ^ble: /etc/security/passwd
ble:
password = 4OdI1uNo3l/0M
lastupdate = 1175851869
flags = ADMCHG


 
dsh (Distributed Shell) is a very nice tool for your case!


If you want to run commands on multiple hosts, first include the hosts in a file (newline-spearated)

Then do the following to that file (supposed its name is hello)

Code:
# export WCOLL=/hello
# dsh –r ssh 'df –k;ls'

This will run in all hosts that are located in the hello file! Very nice command!

But i'm not sure how this would be used in your case to be honest!

You can do this as well

Code:
# for i in host1 host2 host3 host4;
do ssh $i ‘df -k; ls’; done

Regards,
Khalid
 
Hi All
Thanks you to all for the response. Especially to Dziadzia .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top