problem using ssh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting problem using ssh
# 1  
Old 02-26-2009
problem using ssh

Hi,

I have 2 users say user a and user b both in different unix boxes.

I thave to execute a script in user b via user a.

I tried using ssh for it but my script is not getting executed.

My script goes as:
from user a-
ssh userb@host " sh script.sh"
script.sh is placed in user b only.

Can anyone help me out here??

Thanks in advance...
# 2  
Old 02-26-2009
It looks like it should be working. I gave it a try with two machines I have, and it worked. I tried it with and without the quotation marks, and also by making the file executable and adding a shebang line instead of calling the shell first. Every combination worked. It's kind of a dumb question, but have you tried "bash" instead of "sh"?

Does it work if you log into the other server and manually run the file with "sh filename"?
# 3  
Old 02-27-2009
problem using ssh

Hi,
Yes the script does gets executed when logged on from another server

I tried to debug the problem and i got the following error.

MY script :
ssh2 -d -l -n o2oenv8@10.40.6.172 "sh test4.sh"

Debug error

debug: Connecting to 10.40.6.172, port 22... (SOCKS not used)
debug: client supports 3 auth methods: 'publickey,keyboard-interactive,password'
debug: Ssh2Common/sshcommon.c:496: local ip = 10.40.6.172, local port = 61722
debug: Ssh2Common/sshcommon.c:498: remote ip = 10.40.6.172, remote port = 22
debug: Remote version: SSH-2.0-ReflectionForSecureIT_6.1.0.16
debug: Remote host key found from database.
debug: server offers auth methods 'publickey,password'.
debug: Constructing and sending signature in publickey authentication.
debug: Ssh2AuthPubKeyClient/authc-pubkey.c:1615: Public key authentication was successful.
Authentication successful.
debug: Requesting X11 forwarding with authentication spoofing.
rcmd: -l: Unknown host

test4.sh[9]: test: Specify a parameter with this command.
rcmd: -l: Unknown host
test4.sh[18]: test: Specify a parameter with this command.
rcmd: -l: Unknown host
test4.sh[28]: test: Specify a parameter with this command.
test4.sh[35]: test3.sh: not found.
debug: Got session close with exit_status=1


Can anyone help me out here??

Thanks in advance...
# 4  
Old 03-02-2009
problem using ssh

Is the question I asked unanswerable?? Or is it too simple??

Can anyone help??
# 5  
Old 03-02-2009
Quote:
Originally Posted by Taranjeet Singh
Is the question I asked unanswerable?? Or is it too simple??

Can anyone help??
What have you looked at, after reading those error messages you posted? Notice that you're getting multiple errors in your script when trying to run something called "test."

Also, are you attempting to run something that is graphical? I see something in the comments regarding X forwarding, but I don't see the -X or -Y flag in your command. Do "man ssh" to see which of those options you have available, and figure out if you need them for what you are doing.
# 6  
Old 03-02-2009
Hi,
Try this:
1) add user a on the .ssh for ssh without password
2) ssh you@host << EOF
./script
EOF

Let me know if it's work.
# 7  
Old 03-02-2009
Quote:
Originally Posted by Taranjeet Singh
Hi,
Yes the script does gets executed when logged on from another server

I tried to debug the problem and i got the following error.

MY script :
ssh2 -d -l -n o2oenv8@10.40.6.172 "sh test4.sh"

Debug error

debug: Connecting to 10.40.6.172, port 22... (SOCKS not used)
debug: client supports 3 auth methods: 'publickey,keyboard-interactive,password'
debug: Ssh2Common/sshcommon.c:496: local ip = 10.40.6.172, local port = 61722
debug: Ssh2Common/sshcommon.c:498: remote ip = 10.40.6.172, remote port = 22
debug: Remote version: SSH-2.0-ReflectionForSecureIT_6.1.0.16
debug: Remote host key found from database.
debug: server offers auth methods 'publickey,password'.
debug: Constructing and sending signature in publickey authentication.
debug: Ssh2AuthPubKeyClient/authc-pubkey.c:1615: Public key authentication was successful.
Authentication successful.
debug: Requesting X11 forwarding with authentication spoofing.
rcmd: -l: Unknown host

test4.sh[9]: test: Specify a parameter with this command.
rcmd: -l: Unknown host
test4.sh[18]: test: Specify a parameter with this command.
rcmd: -l: Unknown host
test4.sh[28]: test: Specify a parameter with this command.
test4.sh[35]: test3.sh: not found.
debug: Got session close with exit_status=1


Can anyone help me out here??

Thanks in advance...
It seems your test4.sh on 10.40.6.172, doesn't know the host you are trying to get to. So your login is successful, but the remote execution is broke.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem with ssh -n IP

I am able to login to server x from y in shell script. But after that command is get executed on server y. I need the command to be executed on server x. Ex. ssh -n 0.0.0.X ls -ltr Above script I am executing from 0.0.0.Y I got result but it executed on server Y server. But when I use ssh... (4 Replies)
Discussion started by: babapatil14
4 Replies

2. Red Hat

Problem with ssh

Hi , I have done the following things, but still i am not able to connect remote system without enter password. steps: 1) ssh-keygen -t rsa 2) transfered id_rsa.pub file into remote server. 3) I hve redirect id_rsa.pub content to authorized_keys file. Note: I have done the same in another... (6 Replies)
Discussion started by: maniapr08
6 Replies

3. Solaris

Problem with SSH

Hi guys. I am using VirtualBox to run Solaris on my host (Windows 7) . I have setup networking and am able to ping from Solaris to Windows 7 and vice versa. Now I want to be able to SSH from Windows 7 to my guest (Solaris) On solaris , the output to ps -ef | grep ssh shows: ... (8 Replies)
Discussion started by: Junaid Subhani
8 Replies

4. Shell Programming and Scripting

Problem with SSH

Hello, i have 10 machines, machine A execute this script: This is my script: nb_lignes=`wc -l $1 | cut -d " " -f1` for i in $(seq $(($nb_lignes - 1)) ) do machine=`head $1 -n $i | tail -1` machine1=`head $1 -n $nb_lignes | tail -1` ssh root@$machine -x " scp /home/file.txt... (7 Replies)
Discussion started by: chercheur857
7 Replies

5. Shell Programming and Scripting

Problem in ssh

Hello All, Iam using the following command to get the details from a remote server. ssh server2 su - mqm -c "sh /var/mqm/test1.sh" The control will not come out once I run this command. I have set up the required public/private key between server1 and server2 and it works... (3 Replies)
Discussion started by: balaji83it
3 Replies

6. Red Hat

SSH problem

Hey, I have a Red Hat 5.2 machine with : 2.6.18-92.el5 kernel PRM's: openssh-4.3p2-29.el5 openssh-clients-4.3p2-29.el5 openssl-0.9.8e-7.el5 openssh-server-4.3p2-29.el5 openssl-0.9.8b-10.el5 openssl-devel-0.9.8e-7.el5 openssh-askpass-4.3p2-29.el5 I'm trying to transfer files to a... (2 Replies)
Discussion started by: eliraza6
2 Replies

7. Shell Programming and Scripting

ssh script problem problem

Hi Please help me with the following problem with my script. The following block of code is not repeating in the while loop and exiting after searching for first message. input_file ========== host001-01 host001-02 2008-07-23 13:02:04,651 ConnectionFactory - Setting session state... (2 Replies)
Discussion started by: pcjandyala
2 Replies

8. UNIX for Advanced & Expert Users

problem with ssh

Hi I am using ssh and facing problem. When I execute a command which is my application specific it hangs after giving initial message.Program does not return to command prompt but process is completed in background. e.g I run following command $ dtsbackup... (4 Replies)
Discussion started by: shreedhar_tase
4 Replies

9. UNIX for Advanced & Expert Users

SSH v2 problem

Hi, What the problem is that we have a client that has now decided to use SSH protocol 2 only for their internal security audit. This is not a problem except now our SCO system will not connect. I can connect with putty from a windows box fine until the SCO system tries to access which then... (0 Replies)
Discussion started by: Bilb
0 Replies

10. UNIX for Advanced & Expert Users

SSH Problem auth problem

Hi, Just recently we seem to be getting the following error message relating to SSH when we run the UNIX script in background mode: warning: You have no controlling tty. Cannot read confirmation.^M warning: Authentication failed.^M Disconnected; key exchange or algorithm negotiation... (1 Reply)
Discussion started by: budrito
1 Replies
Login or Register to Ask a Question