How to run a remote command in PuTTY after login & keep the shell running?
What the -m
does is, that it makes PuTTY instruct the SSH server to start that command(s) INSTEAD of a shell. So once your command finishes, so does the session.
If you want to run the shell after the cd
command, you need to add it explicitly to your cmd.txt
, like:
cd /my/path ; /bin/bash
Also the -m
implies "nopty"/non-interactive mode. To use an interactive shell you need to override that using the -t
switch.
putty.exe -ssh example.com -m "c:\path\cmd.txt" -t
Alternatively use KiTTY with its -cmd
switch, that does what you want (and does not need a temporary file).