i wanto hardcode password for a username to ssh to a server using script

Dear all

i want to ssh to a server via running a shell script with a username and i want to hard code the password for that particular username

can u help me please

Thank u
Naree

Sure, can we see the script sample ? Also, what does 'hardcoded' mean ?

What you want to do is create an ssh key for the user.
In a nutshell, create an ssh key for your user in serverA using ssh-keygen, then move the *.pub file that ssh-keygen creates to that user's .ssh directory into authorized_keys.
Then you don't need a passwd.
This is well documented. A web search should yield a detail procedure.

i want to hard code password for a particular user mean that

i have written a shell script like this:

ssh user@hostname

password <password>

cd dir

exit

It is always good to follow the procedure mentioned by #System shock.
You need not to hardcode your password anywhere.

Hi all,

please can u help me .. with the procedure .. to create ssh-keygen for a user ...
there after to copy which files?

Thank U
Naree

this may help you

To hardcode the password in a script use the expect command.

A google on solaris expect will give heaps of examples.

Solaris 10 dvd has expect 5.39 on it.

Don't forget to check return codes

Dear All
Mani's procedure really worked but i want .. to do my operations using shell scripting only

for suppose i have written a script in hostB as

ssh user@hostA

cd <<Directory>>

ls -ltrh

exit

The above Directory is in hostA and i want to display list of files in that directory and come out shell script ..

but rather i m being taken to hostA console..

Can we do operations through only shell script is it possible??? Help me

Thank U
Naree