When trying to login with plink to a server I don't know how to pass the sudo password in the command correctly.
I use something like this:
plink -ssh -t <user>@<server> -pw <password> "echo -e <password>\n | sudo -S docker ... | cd <some path>"
The password contains 2 special chars - a ";" and a "*" char. In the first place the ";" char needs to be escaped with a "^" and a connection can be established. Then in the command I need to switch to sudo to use a docker command. Usually it should take the pass from the console. But somehow it seems that there a different escaping is needed. I tried some things and added single quotes around the password in the second place, tried it with and with the linebreak behind the pass but none of the things I tried worked. Anyone knows how to make it work?
Let's say an example password is: abc123;*
When I use this text in the bat-file:
SET password=abc123;*
plink -ssh -t <username>@<server> -pw abc123^;* "echo -e %password%\n | sudo -S docker exec -i <docker_container> <docker_container_path> |pwd"
What I would expect is that after this code the user would be in the docker container and a tomcat path would be displayed. But instead the current directory after the connect is displayed and below there are those lines:
[sudo] password for <user>: Sorry, try again
[sudo] password for <user>:
sudo: 1 incorrect password attempt
I tried diffent approaches to escape the password for the plink command like:
SET password=abc123\;\* or
SET password=abc123%%3B%%2A or SET password=abc123^;*
but none of them worked.
Note: Unfortunately changing the user password or setting the linux server to "no password" is not an option.