ssh and commands

can someone point me to where it explains how to set the right commands wd ssh?

cat something | while read h; do awk 'BEGIN {FS="\n"; RS=""; ORS="\n\n"} {if ($0~/'$h'/) print hdrvar,"\n",$0 }' /something/somedata ; done

above works in when ssh'ing into linux machine invoke like this

ssh server1 cat something | while read h; do awk 'BEGIN {FS="\n"; RS=""; ORS="\n\n"} {if ($0~/'$h'/) print hdrvar,"\n",$0 }' /something/somedata ; done

but when I try to ssh'ing into older solaris machine, it does not work.. when i try to put " " around all the commands after ssh server1... it complains about error in awk...

why?

  1. All that is executed on the remote server is "cat something".

  2. What implementation of sshd is on the Solaris box?

  1. All that is executed on the remote server is "cat something".

no.. everything is being executed on the remote server after ssh'ing into the machine

  1. What implementation of sshd is on the Solaris box?
    I am trying to understand what kind of answer you are looking for.. can you please elaborate?

Having

ssh user@machine cat something | do more stuff

would mean only "cat something" executes on the remote machine.

OpenSSH? SSH2? What version?

it's open sshd and it handles both version 1 and 2..

this is definitely furstrating issue.
No where in google that I have come across where it clearli explains how to do multiple commands through pipes in remote server..

I really would like the help of this..

please let me know.. right syntax is i guess what i am looking for.. but i have tried lot.. and it's all no good.. and for now.. i have no choice but to do multiple ssh into same server to get the answer what i am looking for.. but that's just not efficient

glad you are thinking!

You can actually pipe a shell script into ssh, eg

echo "ls -l; pwd; uname -a" | ssh me@somewhereelse

that might help.

I will try that.. i wonder if small shell script will work that consist of multiple pipes that needs to be excuted on remote servers..

also, one more question.. this i created this script so that others can use.. but i dont want them to type in the passwd.. I already have authorized_keys setup.. so i dont need to type passwd when i run .. but i dont want others to type in passwd either..

I thought I could give the script set uid as me.. and add path to my home directory's .ssh.. and in the script run as me.. e.g., ssh myid@remoteserver

but this does not work..

any idea?

either

  1. each user has their own entry in the remote machines $HOME/.ssh/authorized_keys file; or

  2. you identify the private key file as a command line argument to ssh.

Really? argument as command line for ssh.. let me look into that and get back to you.

I guess this is not possible.. I used it and it worked once.. and then after that, I try to log on, and it spits out saying since my id_dsa file is readable by others, it is consider bad and i need to make a new one.. I guess only way to now accomplish is to use expect...

So at least you do know that either each user needs there own identity or at least their own copy of the same file owned by them with attributes set to -rw------. You identify the file by `whoami` or $LOGNAME.