SSH usage in a script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SSH usage in a script
# 1  
Old 02-14-2007
SSH usage in a script

I have configured ssh to a remote server without prompting for a password with the help of public keys...but now i am not able to execute any commands through a script

what i want is a one line script which takes me directly into /var directory after executing it...searched the entire forum but couldnt find a solution to this prob...

i have tried...

ssh username@hostname "cd /var"
ssh username@hostname [cd /var]
ssh username@hostname ; cd /var
ssh username@hostname | cd /var

nothing seems to work :-(
# 2  
Old 02-14-2007
Er, what exactly are you trying to do? And how do you know that the command
Code:
ssh username@hostname "cd /var"

didn't work? Are you expecting that you will get a prompt after doing the cd to /var? If so, you are mistaken. Try executing this:
Code:
ssh username@hostname "uname -a; cd /var; pwd"

You will see that you are indeed on the remote server and in the /var directory. However you aren't specifying any more actions to be carried out, so your ssh command is getting completed and exiting.
# 3  
Old 02-14-2007
thanks

Gr8!! now i am getting my commands to execute...didnt know ssh returns back after executing :-) Thanks...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Ssh script to validate ssh connection to multiple serves with status

Hi, I want to validate ssh connection one after one for multiple servers..... password less keys already setup but now i want to validate if ssh is working fine or not... I have .sh script like below and i have servers.txt contains all the list of servers #/bin/bash for host in $(cat... (3 Replies)
Discussion started by: sreeram4
3 Replies

2. Shell Programming and Scripting

Shell script to calculate the max cpu usage from the main script

Hi All, I have a script which does report the cpu usuage, there are few output parameter/fields displayed from the script. My problem is I have monitor the output and decide which cpu number (column 2) has maximum value (column 6). Since the output is displayed/updated every seconds, it's very... (1 Reply)
Discussion started by: Optimus81
1 Replies

3. Red Hat

Xinetd flags and tcp46 socket usage to telnet / ssh via v4 and v6 addresses

Hello everyone.. I need some help in understanding the usage of tcp46 socket and xinetd.d flags.. What I'm trying to do? I'm looking to use tenet via tcp46 socket for both ipv4 and ipv6 traffic. For this, if i set flags = IPV6 xinetd.d, telnet service, i can not telnet via V4. If I unset the... (0 Replies)
Discussion started by: Sudharshan
0 Replies

4. Shell Programming and Scripting

Need help on ssh usage in a loop of shell script

I need help on how to connect remote systems through ssh command in while loop of shell script. I was able to connect one remote system using ssh from shell script. Please find sample code snippet as given below….. ssh "root@148.147.179.100" ARG1=$rpmFileName 'bash -s' <<'ENDSSH' ... (5 Replies)
Discussion started by: rajesh.tulluri
5 Replies

5. Shell Programming and Scripting

SSH and It's usage

Hi , I was going through a script and I saw following commands :-- OPTS="-e /usr/local/bin/ssh -ralpgHSvuz --stats --rsync-path=/usr/local/bin/rsync" OPTS="-e /usr/local/bin/ssh -vrlopgt --stats --rsync-path=/usr/local/bin/rsync" Can someone please explain the meaning of words... (4 Replies)
Discussion started by: Abhayman
4 Replies

6. Shell Programming and Scripting

SSH Usage

Hi, When i am using SSH, trying to automate some process, it seems as I am loosing environment settings that belongs to proper running of jboss server. On Server (X) a User (A) is trying to run a jboss server but the location of jboss is on the same server (X) but on different user (B) . The... (1 Reply)
Discussion started by: nimrodt
1 Replies

7. AIX

How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..?

How to monitor the IBM AIX server for I/O usage, memory usage, CPU usage, network usage, storage usage? (3 Replies)
Discussion started by: laknar
3 Replies

8. UNIX for Dummies Questions & Answers

Restricting SSH usage

Hello, For one of our servers, we have had people trying to illegally loggon using the ssh service. My manager has asked me to restrict ssh access to users in our internal network but close ssh access to the "outside" world. Could someone at the very least point me to some resources on the... (7 Replies)
Discussion started by: mojoman
7 Replies

9. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

10. UNIX for Dummies Questions & Answers

Enabling backspace usage in Putty SSH connection ?

I have started a new job for 2 weeks not. I am distributing software packages through Tivoli and connecting to the servers using Putty in X11 and SSH. But on the command line, the backspace is disabled. I know its a command I have to enter in my .profile but I don't remember. There is a Ctrl+H... (2 Replies)
Discussion started by: Browser_ice
2 Replies
Login or Register to Ask a Question