Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I Have created a shell script as given below.This script will login to a remote server as a normal user then switch to root user for creating a directory.The script is as given below.

ssh -t qbadmin@10.3.2.0 '
su root -c "
echo \"Give Directory name :\";
read dir;
mkdir \$dir;
";
'

Here the script will ask Password for normal user first.Then again it will ask for root Password.How could I automate this using expect command.I want to supply the password automatically for the root user only.I think it can be done with expect.

Please do help me.

share|improve this question
    
What about authorized keys? help.ubuntu.com/community/SSH/OpenSSH/Keys More security! –  prophecy201 Mar 19 '13 at 10:52

1 Answer 1

If you want to pass only the root password, you have to

  • either configure a password-less login into the user account, e.g. using public key authentication and an ssh agent on the client side,
  • or configure the server (i.e. to allow login as root, and then do ssh -t root@10.3.2.0 …
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.