I'd like to be able to setup a command to run on ssh login to a server, without needing to type it. Basically I'm looking for the ssh config file equivalent of:

ssh host command

so that all I need to type is:

ssh host

and the command gets run.

link|improve this question

17% accept rate
feedback

2 Answers

You could set up a bash alias.

In your .bashrc file, put:

alias ssl='ssh some_host run_command'

Then you wouldn't even have to type the hostname.

Or, if you wanted to do this with multiple hosts(and multiple aliases wouldn't work), then use a small script:

kevin@box:~$ cat ssl.sh
#!/bin/sh
ssh $1 some_command
kevin@box:~$
link|improve this answer
feedback

If you are running OpenSSH, it looks like ~/.ssh/rc is executed upon login.

link|improve this answer
1  
Is /.ssh/rc located on the client or server machine? Looks like from the docs the server, right? – heavyd Mar 25 '10 at 18:45
Yes, that would be on the server machine. – coneslayer Mar 25 '10 at 18:52
feedback

Your Answer

 
or
required, but never shown

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