Operating System - HP-UX
1834694 Members
2204 Online
110069 Solutions
New Discussion

Re: How to SSH for remote execution

 
SOLVED
Go to solution
santosh jha
Frequent Advisor

How to SSH for remote execution

Hi ,

I am designing a script where i need to execute some commands on different server from one server.

Previously i was using "remsh" to accomplis this but now i have to move away from "remsh" and use "ssh" instead.

Please guide me how to do it.

Regards

Santosh Jha
8 REPLIES 8
Sivakumar TS
Honored Contributor
Solution

Re: How to SSH for remote execution

Dear Santosh,

Check out this link

http://www.employees.org/~satch/ssh/faq/INSTALL.txt

HtH,

Siva.
Nothing is Impossible !
Senthil Prabu.S_1
Trusted Contributor

Re: How to SSH for remote execution

Hi,
you can use your script as before, only changing the remsh with ssh [correct syntak]. check man ssh for syntak.


Also, you can use use public key authentication using SSH which helps a lot in automation so that password less authentication happends between two machines.
One man's "magic" is another man's engineering. "Supernatural" is a null word.
santosh jha
Frequent Advisor

Re: How to SSH for remote execution

Senthin could you please me the command if for example i am in "server1" logged in as "oracle" and i want to execute "ls" on "server2" with the same user on that machine.
Thummalu
Frequent Advisor

Re: How to SSH for remote execution

here it is

if both the servers are having correct host based authentication keys, then
from server1

ssh -q server2 ll

will work fine :)

br
Thummalu
Senthil Prabu.S_1
Trusted Contributor

Re: How to SSH for remote execution

Hi santhosh,
ssh -l oracle server2 ls


This you have to incorpate in your script on the server1.

If you want to do many operations on remote m/c, then

ssh -l oracle server2 << EOF
ls
pwd
netstat -na
EOF

hth,
Prabu.S

If you want steps for using pasword less authentication, I can also send them
One man's "magic" is another man's engineering. "Supernatural" is a null word.
Arunvijai_4
Honored Contributor

Re: How to SSH for remote execution

You need to work on password less authentication with SSH server and client, have a look at this thread, it will guide you

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=851253

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Jaroslav Matys
Respected Contributor

Re: How to SSH for remote execution

Just briefly:
1) Generate your identity on unix_box

If you already have created your identity (file /home/your_login/.ssh/id_rsa exists), please skip this step otherwise you will destroy your previous setup.
This setup you will do only once per user and system.

ssh-keygen -t rsa

2) Distribute your identity to other nodes
This setup you have to do for every user and system from which you want to conect for all users and systems you want to connect to :
2.1 Create .ssh directory on targer_node
ssh target_user@target_node [ ! -d /home/your_login/.ssh ] && (mkdir /home/your_login/.ssh;chmod 700 /home/your_login/.ssh)
2.2 Copy your public identity to target
cat /home/your_login/.ssh/id_rsa.pub | ssh target_user@target_node tee -a /home/your_login/.ssh/authorized_keys

3) Simply use ssh and scp or sftp
ssh target_node
ssh your_login@target_node
ssh your_login@target_node command parameter
Tor-Arne Nostdal
Trusted Contributor

Re: How to SSH for remote execution

Just a small comment to Jaroslav's nice description.
Substitute: /home/your_login
with: ~your_login

~your_login will point to the home-directory of user your_login regardless if it is on /home or elsewhere...

/2r
I'm trying to become President of the state I'm in...