LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need help to execute command on Remote machine (https://www.linuxquestions.org/questions/linux-newbie-8/need-help-to-execute-command-on-remote-machine-696029/)

tucs_123 01-09-2009 01:24 AM

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

colucix 01-09-2009 01:30 AM

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"

tucs_123 01-09-2009 01:40 AM

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?

jschiwal 01-09-2009 01:47 AM

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.

colucix 01-09-2009 02:03 AM

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.