Need help to execute command on Remote machine
Hi,
I need to find the storage capacity of warehouse present on the remote server. My requirements are: 1)Connect to the remote server 2)Change the directory to particular directory and 3)Know the capacity of warehouse. Say my commands are: 1)cd /server/warehouse 2)df -k warehouse44 How do I execute above commands on remote server. When I use ssh tucs_123@xyz.com 'cd /server/warehouse|df -k warehouse44' I get message: df: (warehouse44) not a block device, directory or mounted resource |
Since they are two different commands, you can use a semicolon to run them in sequence. Piping the output from one command to the other triggers this error. Moreover, you don't really need to change directory. Just do
Code:
ssh tucs_123@xyz.com "df -k /server/warehouse/warehouse44" |
Hey Thanks buddy...It worked......One more thing..If ssh command is executed..It asks for the password.How do I set the password for the server so that I will be able to login to server automatically?
|
A bad idea is to use "expect". A better idea is to use configure the server to use public key authentication. The values to change are given in the paragraph of comments above the "UsePAM" line. Then append the public ssh key (rsa or dsa) to the authorized_keys file on the server.
|
Yes, set Public Key Authentication. There are plenty of tutorials about this task. Look for them, but first read man ssh. The AUTHENTICATION section gives a good description of the issue.
|
All times are GMT -5. The time now is 12:30 AM. |