You need to create a file with two commands, the directory change and the shell start, like:
cd /path /bin/bash
Then use the command-line parameter -m
to "execute" the commands. You will also want to use the -t
for force TTY back as the -m
disables it.
putty.exe username@example.com -pw password -t -m commands.txt
To avoid a separate command file for each sessions, just generate it from the batch file:
set SCRIPT_FILE=%TEMP%\commands.txt echo cd /path > %SCRIPT_FILE% echo /bin/bash > %SCRIPT_FILE% putty.exe username@example.com -pw password -t -m %SCRIPT_FILE%
References:
- PuTTY command-line
- Starting PuTTY session in a specific directory
- PuTTY: Run a remote command after login & keep the shell running
If you want GUI for managing sessions with specific initial remote path, you can use WinSCP.
- WinSCP can work as session manager for PuTTY
- and it can be configured to open PuTTY in a specific path.
(I'm the author of WinSCP)