Passing a command over SSH


 
Thread Tools Search this Thread
Operating Systems AIX Passing a command over SSH
# 1  
Old 04-14-2008
Passing a command over SSH

I'm trying to run a command over ssh to AIX 5.2, something like:

Code:
ssh machine ls

but it just hangs. I can ssh into the machine and run a command, but can't pass it like above. Is there a security setting that disables this by default? If so, how do I change it?

Thanks!
# 2  
Old 04-14-2008
look at (and post) the output of
$ ssh -vvv <machine> ls
# 3  
Old 04-14-2008
Here it is:

Code:
OpenSSH_3.5p1, SSH protocols 1.5/2.0, OpenSSL 0x0090701f
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Rhosts Authentication disabled, originating port will not be trusted.
debug1: ssh_connect: needpriv 0
debug1: Connecting to beckman [192.168.1.148] port 22.
debug1: Connection established.
debug1: identity file /home/tai/.ssh/identity type -1
debug1: identity file /home/tai/.ssh/id_rsa type -1
debug3: Not a RSA1 key file /home/tai/.ssh/id_dsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: no key found
debug3: key_read: no space
debug3: key_read: no space
debug3: key_read: no space
debug3: key_read: no space
debug3: key_read: no space
debug3: key_read: no space
debug3: key_read: no space
debug3: key_read: no space
debug3: key_read: no space
debug3: key_read: no space
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: no key found
debug1: identity file /home/tai/.ssh/id_dsa type 2
debug1: Remote protocol version 1.99, remote software version OpenSSH_3.8.1p1
debug1: match: OpenSSH_3.8.1p1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_3.5p1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib
debug2: kex_parse_kexinit: none,zlib
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib
debug2: kex_parse_kexinit: none,zlib
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: mac_init: found hmac-md5
debug1: kex: server->client aes128-cbc hmac-md5 none
debug2: mac_init: found hmac-md5
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: dh_gen_key: priv key bits set: 125/256
debug1: bits set: 1611/3191
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug3: check_host_in_hostfile: filename /home/tai/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 13
debug3: check_host_in_hostfile: filename /home/tai/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 13
debug1: Host 'beckman' is known and matches the RSA host key.
debug1: Found key in /home/tai/.ssh/known_hosts:13
debug1: bits set: 1570/3191
debug1: ssh_rsa_verify: signature correct
debug1: kex_derive_keys
debug1: newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: waiting for SSH2_MSG_NEWKEYS
debug1: newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: done: ssh_kex2.
debug1: send SSH2_MSG_SERVICE_REQUEST
debug1: service_accept: ssh-userauth
debug1: got SSH2_MSG_SERVICE_ACCEPT
debug1: authentications that can continue: publickey,password,keyboard-interactive
debug3: start over, passed a different list publickey,password,keyboard-interactive
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: next auth method to try is publickey
debug1: try privkey: /home/tai/.ssh/identity
debug3: no such identity: /home/tai/.ssh/identity
debug1: try privkey: /home/tai/.ssh/id_rsa
debug3: no such identity: /home/tai/.ssh/id_rsa
debug1: try pubkey: /home/tai/.ssh/id_dsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: input_userauth_pk_ok: pkalg ssh-dss blen 433 lastkey 0x8090280 hint 2
debug2: input_userauth_pk_ok: fp 06:c4:57:20:81:db:f4:27:b5:3c:8f:54:75:a2:04:47
debug3: sign_and_send_pubkey
debug1: read PEM private key done: type DSA
debug1: ssh-userauth2 successful: method publickey
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug1: send channel open 0
debug1: Entering interactive session.
debug2: callback start
debug1: ssh_session2_setup: id 0
debug1: Sending command: ls
debug1: channel request 0: exec
debug2: callback done
debug1: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel 0: rcvd adjust 131072

It hung, and I hit Ctrl-C:

Code:
debug1: channel_free: channel 0: client-session, nchannels 1
debug3: channel_free: status: The following connections are open:
  #0 client-session (t4 r0 i0/0 o0/0 fd 4/5)

debug3: channel_close_fds: channel 0: r 4 w 5 e 6
Killed by signal 2.
debug1: Calling cleanup 0x805b060(0x0)
debug1: Calling cleanup 0x80674d0(0x0)

At this point, I think it crashes and reboots... it doesn't even respond to a ping.

Code:
OpenSSH_3.5p1, SSH protocols 1.5/2.0, OpenSSL 0x0090701f
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Rhosts Authentication disabled, originating port will not be trusted.
debug1: ssh_connect: needpriv 0
debug1: Connecting to beckman [192.168.1.148] port 22.
debug1: connect to address 192.168.1.148 port 22: No route to host
ssh: connect to host beckman port 22: No route to host

# 4  
Old 04-14-2008
Are the keys exchanged and do you have to enter a password/passphrase? It does look like you have not exchanged the keys between the two machines.

A common gotcha is that ssh assumes the user to be named the same on both machines until told otherwise. That means "user@machine1" issuing "ssh machine2" will implicitly try to connect as "user@machine2". This is not always what is intended. Many times you want to connect to machine2 as "root" or so. You willl have to explicitly tell this to ssh by using one of the two syntaxes:

Code:
user@machine1 # ssh anotheruser@machine2
user@machine1 # ssh machine2 -l anotheruser

If the user "user" would not exist on machine2 ssh won't tell you so (by issuing an error like "no such user") because this would be a way to find out which users exist and which don't on machine2 without even connecting to it.

I hope this helps.

bakunin
# 5  
Old 04-14-2008
I have handshaking set up between the two machines, and they're both using the same username.

So "ssh tai@beckman" works, but "ssh tai@beckman ls" doesn't.
# 6  
Old 04-15-2008
Quote:
Originally Posted by hansnueski
Here it is:

Code:
[snip]
debug1: ssh-userauth2 successful: method publickey
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug1: send channel open 0
debug1: Entering interactive session.
debug2: callback start
debug1: ssh_session2_setup: id 0
debug1: Sending command: ls
debug1: channel request 0: exec
debug2: callback done
debug1: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel 0: rcvd adjust 131072

It hung, and I hit Ctrl-C:

Code:
debug1: channel_free: channel 0: client-session, nchannels 1
debug3: channel_free: status: The following connections are open:
  #0 client-session (t4 r0 i0/0 o0/0 fd 4/5)

debug3: channel_close_fds: channel 0: r 4 w 5 e 6
Killed by signal 2.
debug1: Calling cleanup 0x805b060(0x0)
debug1: Calling cleanup 0x80674d0(0x0)

At this point, I think it crashes and reboots... it doesn't even respond to a ping.

Code:
OpenSSH_3.5p1, SSH protocols 1.5/2.0, OpenSSL 0x0090701f
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Rhosts Authentication disabled, originating port will not be trusted.
debug1: ssh_connect: needpriv 0
debug1: Connecting to beckman [192.168.1.148] port 22.
debug1: connect to address 192.168.1.148 port 22: No route to host
ssh: connect to host beckman port 22: No route to host


Your ssh connection appears to work but at three occasions in your debug output it seems like you simply don't get what the target node returns. The ping not returning to your node does not necessarily imply that your target node is dead/rebooting (check with who -b). There may be a problem with the routing. Do both nodes have a route defined to the other node? Can you connect to the originating node from node "beckman"?
# 7  
Old 04-15-2008
Quote:
Originally Posted by shockneck
Your ssh connection appears to work but at three occasions in your debug output it seems like you simply don't get what the target node returns. The ping not returning to your node does not necessarily imply that your target node is dead/rebooting (check with who -b). There may be a problem with the routing. Do both nodes have a route defined to the other node? Can you connect to the originating node from node "beckman"?
Connecting from beckman to the originating machine works fine. I can connect normally over ssh to beckman and run commands (and receive a response) when I'm logged in, so it seems to me like it wouldn't be a routing issue...

I also checked who -b, and the last boot was just after I attempted the "ssh tai@beckman ls" command.

Thanks for your suggestions so far... hopefully we can figure this out.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing a variable via ssh, can't quite get it right

Hi Guys n Girls, Below im using a while command to wait for a file on another server then carrying on with the script..... I dont believe the $Sausage1 variable is being passed to the other server so its not finding the file. If i replace the variable with the date then it works as expected. ... (2 Replies)
Discussion started by: twinion
2 Replies

2. Shell Programming and Scripting

Passing password with SSH command

Hi Experts, I have specific requirement where I want to pass the password with the ssh username@hostname command . I dont want to use RSA public and private keys also. Because that will be on production server and no one wants to give access like that. Second thing it is production... (14 Replies)
Discussion started by: sharsour
14 Replies

3. Shell Programming and Scripting

Connect (SSH) to Windows server via Linux server through a script and passing command.. but failing

I am trying to connect to Windows server via Linux server through a script and run two commands " cd and ls " But its giving me error saying " could not start the program" followed by the command name i specify e g : "cd" i am trying in this manner " ssh username@servername "cd... (5 Replies)
Discussion started by: sunil seelam
5 Replies

4. Shell Programming and Scripting

Passing password for ssh in Script

I want to do following 2 commands via script: 1) eval `ssh-agent`2) ssh-add /export/home/sufuser/.ssh/id_rsa When asked for passphrase enter "passwordpassword1234 but whenever I run the script it stucks after "ssh-add /export/home/sufuser/.ssh/id_rsa" command and asks fro... (4 Replies)
Discussion started by: yogeshpawar
4 Replies

5. Shell Programming and Scripting

Passing password in script for ssh connection - no except

Used the script posted on forum - unix.com/shell-programming-scripting/21597-script-change-passwords-same-user-multiple-servers.html but the last question posted on this seems to be still unanswered, tried different things with no success, can someone help giving an way to pass the password via... (5 Replies)
Discussion started by: sapadmin
5 Replies

6. Shell Programming and Scripting

passing arguments in remote ssh command?

i have a bash script on serverA, when i run the script on the server, it runs fine. the way to run the script is like this ./script "option1" Now i am trying to call it from local laptop using ssh command, my command is as the following ssh serverA ~/script "option1" and i got error... (7 Replies)
Discussion started by: fedora
7 Replies

7. Shell Programming and Scripting

Passing awk through ssh help

First off we have hundreds of webservers in our farm that we sometimes have to collect logs for customers. Thing is the script that I currently am working on doesnt like my awk commands via ssh. I am very novice at best so all help would be greatly appreciated. ssh a$active "awk... (9 Replies)
Discussion started by: gbarnes
9 Replies

8. Shell Programming and Scripting

SSH Login by passing password.

ssh/sftp login by passing password , is it possible.Don't want to expect. (1 Reply)
Discussion started by: dinjo_jo
1 Replies

9. Shell Programming and Scripting

Passing SSH Command Parameters

Hi, I wan to pass arguments to remote script in Unix . For that I'm using ssh PFB the code I'm using: ssh -t -l osdac 10.81.33.51 "cd /appl/OSD/LOGS/flstr010/test.sh "$1" "$2"" Problem is I'm not able to pass second argument . Can anyone plz help me in resolving this. (5 Replies)
Discussion started by: suchitasaner27
5 Replies

10. Solaris

Passing SSH Command Parameters

On Solaris 5.9, is there any way to pass parameter(s), via SSH, to a command defined in the remote host's authorized_keys file? We have a menu that uses SSH to control some apps on our various hosts. I've been tasked with enhancing it and making it more secure. So far, the local host menu... (2 Replies)
Discussion started by: PabloCruise77
2 Replies
Login or Register to Ask a Question