I'm trying to build a Windows batch file, which starts putty/plink with port forwarding, and nothing else. The Windows part is ready so far:
start plink.exe -ssh -i key.ppk -L 1234:localhost:80 sampleUser@192.168.0.1
As I don't want to allow to execute other commands after authentication, I'm using ForceCommand
with a Match User
declaration:
Match User sampleUser
ForceCommand echo 'Success! Close this window to log out.'
Problem is, running my batch file starts putty correctly, but it closes immediately after executing echoing my specified text.
My idea is to use something like this:
ForceCommand echo 'Success! Close this window to log out.' && waitTillControlC
This way, putty/SSH should keep the connection alive and doesn't quit my port forwarding.
I've thought of commands like yes
, ping
or read
, but they
- are spamming my terminal window
- are actually doing stuff / generating unnecessary CPU load
- could close unexpectedly, if someone presses enter
Is there a command which will do nothing, forever, till somebody terminates it with Ctrl+C or closes the SSH connection by closing the putty window?
What should I use for waitTillControlC
?