How can my unix shell script automatically connect to remote host?

How can my unix shell script automatically connect to remote host?

Assume that there is a remote host called "rhost". When I connect to that host i give the command "telnet rhost".

It then asks me for my id and password. Once i give it connects there.

I want to automate these steps. I want a shell script which will automatically connect to 'rhost'. I shall provide my userid and password in the shell script.

What i need is just to run that shell script and the script will connect me to 'rhost'.

CAN SOME ONE HELP ME TO WRITE THIS SCRIPT?

IT WOULD BE BETTER IF YOU CAN GIVE ME THE SCRIPT.

I WORK IN SOLARIS/ K-SHELL.

Thanks
Digdarshan

This smacks of a homework question, and what's more this:

indicates you are particularly bad student. You shouldn't wish for people to just write you code on demmand.

Anyway this question has been asked many times before - search the forums.

Of course if you are cunning there are ways where you don't need to provide a userid and password in the shell script :wink: :wink: :smiley:
You just need to make both machines ..........

Have a look at ssh. It features keyed authentication where you do not need to enter a username/password to connect to another machine. There are quite a few articles about this on the web (Daniel Robbins of Gentoo Linux has done a wonderful howto on this with openssh, and even offers a keyring tool called keychain).

links please?

i'm quite interested in this myself now (of course i'm not doing it for my homework! :smiley: neither is my pinky glued to the caps lock key :wink: )

thanks...

The only link you'll ever need:

forget telnet use ssh,
the ssh man-pages describes the way

if u are working on solaris 10, u can use the "ssh-keygen" for authenticate the remote host with the two files id_dsa (private key) and id_dsa.pub (public key). in ".ssh" directory in ur home

I do this all the time

list=/home/syndex/serverlist

for server in $list
ssh -q $id@$server "sudo ..."
done

I do this to push out account adds / administration across 120+ servers.