I am trying to log on to server as a normal user and then sudo to root.
I am using below expect script.
[linux@linux]$ cat SC.orig
expect <<EOF # | tee -a $LOGFILE
spawn sshpass -p "mypassword" ssh -l myid nim
expect "$"
send "sudo su - root\n"
expect "Password:"
send "mypassword\n";
sleep 4
interact
[linux@linux]$
When I run this .. I get below
[linux@linux]$ SC.orig
/home/linux/bin/SC.orig: line 9: warning: here-document at line 1 delimited by end-of-file (wanted `EOF')
spawn sshpass -p mypassword ssh -l myid nim
sudo su - root
mypassword
Last unsuccessful login: Fri Jan 9 09:44:23 2015 on ssh from abcxyx
$ sudo su - root
mypassword
Password:
TERM=xterm
<<<
[nim:/home/root] [linux@linux]$
This script is authenticating me to remote server and then doing sudo to root but then exits from shell and comes back to my local shell.
I want my script to enter passwords and then take me to shell.
Could you please help me with this script ?