Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start SSH connection in PuTTY, run a command, and leave the session active

Tags:

ssh

putty

I want to run a few shell commands every time I SSH to a server via PuTTY. I'm connecting to a production web server managed by someone else, and I don't want to store my own scripts there.

I see the option Connection > SSH > Remote Command, but if I put my initialization commands there, after starting the session, it closes immediately after the commands execute. How can I run the Remote Command, and then keep the session open so I can continue using it?

like image 257
Matthew Marichiba Avatar asked Feb 28 '15 07:02

Matthew Marichiba


1 Answers

The SSH session closes (and PuTTY with it) as soon as the command finishes. By default the "command" is a shell. As you have overridden this default "command" and yet you want to run the shell nevertheless, you have to explicitly execute the shell yourself:

my-command ; /bin/bash

See also Executing a specific command on the server.

like image 191
Martin Prikryl Avatar answered Nov 04 '22 00:11

Martin Prikryl