My problem is similar to this one , I am trying to automate the portion where I can access the remote machine and run a command as super user. It works fine till it logs-in , like from here :-
$ ssh-keygen -t rsa -b 2048
to
$ ssh-copy-id id@server
id@server's password:
$ ssh id@server
id@server:~$
The overhead for me is that I can ask user for remote machine's password only once (while generating ssh keys), and after that while running a command as super user it shouldn't ask for password again i.e It shouldn't need a command like below:-
sudo su
Is there any way I can do it? because I tried saving the password as variable and then substituting the value like :-
echo -n "Enter password > "
read passwd
sshpass -p $username ssh -o StrictHostKeyChecking=no $username@$server sudo some_application &
It will prompt for the password where I cannot substitute the value of the variable I declared.