How to submit Plink "Access granted. Press Return to begin session" prompt automatically

Yves picture Yves · Aug 31, 2019 · Viewed 13.2k times · Source

I'm writing a simple Windows batch script to allow me to execute some Linux command on my remote server with the help of plink.exe.

call set argument1=plink -pw mypwsswd [email protected] cd ~/project; make clean; make -j8
call plink %%argument1%%

In a word, it will rebuild my C++ project on the remote server.

When I double click the batch, it works except that I have to type an Enter each time.

Access granted. Press Return to begin session

enter image description here

As you see, after I getting this windows, I have to type an Enter to continue.

Is there some way to avoid this? For example, typing an enter automatically?

Answer

Martin Prikryl picture Martin Prikryl · Aug 31, 2019

Since PuTTY 0.71 you get that prompt for security purposes, when you login in an interactive mode. See PuTTY vulnerability vuln-auth-prompt-spoofing.

To use a batch mode, use -batch switch. That way you not only get rid of that prompt. It will also make sure the command does not hang on various other prompts that may occur, when something changes. Instead the command fails straight away.

If you want to keep the interactive mode, but avoid this specific prompt only, use -no-antispoof switch.