how to run the script without giving the password.

Hi all,

I need some help in my script...

I need to login into multiple servers from one Unix box and need to login as a superuser account and then I need to perform some actions on the server. For this, i'll use for loop to provide the server names to the script, but for every login as a super user, it is asking user password. so when we are running the script, we are giving the password for every login.
For example, 10 servers are there to login.
To login into the server, it is not asking any passwords, but to login as a super user from the box, it is asking password. So for each box, i am providing the password 10 times.

I dont want to give the password for everytime login, How can I resolve this issue?

can anyone please provide an assistance for the same?

Thanks in advance.

Raghu.

looks like "expect" is the tool you need...

Hi Duke,

Thanks for your reply.

how can i get the "expect" tool? is it free tool?

regards,
raghu.

search on google...you'll get it... its a nice scripting mechanism to automate needs such as yours...

Ok, thank you very much Duke, will search and get it

depending on the distribution you are using, expect is maybe part of your system already. most linux distributions are with expect by default. solaris doesn't have expect by default. i don't know how about aix and othe flavors...

you're logging into the server.. then su'ing to root? perhaps you should just setup nopasswd sudo access to the commands you need as the user you can login to with no passowrd.

Yes tray, i need to login using sudo, but need to provide my user passwd only,

and i need to put this script in cron file, so i cant provide any password.
i am attaching the script, please advice needful, thanks for your reply.

regards,
raghu.

If it's possible, just update your sudoers file on those servers.

username ALL=(ALL) NOPASSWDL:ALL

of course.. thats full root access to the user so you can tailor that down... but with the nopasswd: option you will not need a password.

then you can just add: sudo -u root (or whatever user you want) in front of your find/cleanup commands with no need to store the password in clear text anywhere.