Reputation: 741
I have created a shell script as given below.But it is not reading username and password.What Iam expecting form this script is to login as a normal user to a remote machine and login to root user to run some commands there.
ssh -t [email protected] '
echo "user logined !";
su root -c "
echo Give username :;
read username;
echo Give password :;
read password;
echo $username;
echo $password;
";
'
Upvotes: 3
Views: 292
Reputation: 8272
You need to escape the $
's for the variables inside the quotes:
ssh -t [email protected] '
echo "user logined !";
su root -c "
echo Give username :;
read username;
echo Give password :;
read password;
echo \$username;
echo \$password;
";
'
Otherwise, the shell created by the ssh
command as the qbadmin user is going to perform string interpolation on $username
and $password
before executing the su
command.
Upvotes: 3