2

I want to be able to automatically run PuTTY, connect to a server, and then run a number of commands. For example, in my local development environment I use PuTTY to run a Rails server so the process usually entails me opening PuTTY, loading a saved session which uses SSH authentication key. I then open the session ,enter the password and then run the following commands:

cd /vagrant
RAILS_ENV='development' bundle exec rails s

I have seen suggestions for using .bat files; however, I was hoping for an approach, which means that I also do not have a command prompt window open for every session opened.

Ali Khakbaz
  • 1,057

2 Answers2

0

Save a putty profile with the remote commands. This is the gui equivelant of the -m option.

Remote commandoption in putty configuration: Connection > SSH

putty Configuration

When you say "automatically run putty". There must be a trigger to automatically open this putty profile. I used to use autohotkey, then started using shortcut files in an "aliases" folder which is in my $PATH variable. A shortcut may look something like this in the Target: field "C:\path_to_putty\putty.exe -load profilename

0

plink is Putty's command line tool. Thus, from a Command Prompt window, you can do:

C:\Users\11026270>plink -load A_session -batch cd vmstat; dir; X='foo '; echo "x${X}x"
vmstat_2025-03-13_00:00:01.log
vmstat_2025-03-14_00:00:01.log
xfoo x
RonJohn
  • 403