There is a remote host, where I'd like to run a specific script every time I connect to it via ssh. Where should I put the file to be run automatically?

link|improve this question
feedback

3 Answers

From the ssh man page:

~/.ssh/rc
         Commands in this file are executed by ssh
         when the user logs in, just before the user's
         shell (or command) is started.  See the
         sshd(8) manual page for more information.
link|improve this answer
feedback

Add it to the authorized-keys file for the key you are connecting with (setup a private key auth as well) and use the command field in the file, for more info do a "man authorized-keys" to see what else you can setup.

link|improve this answer
feedback

In the remote server?

ssh my-remote-host /usr/local/bin/my-remote-script

You can limit the ssh to run only one command with a specific key also, thus limiting the key usage. See http://pkeck.myweb.uga.edu/ssh/ for examples

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.