3

I would like to know if there is a way to specify what script to run (on the remote machine) at login. I'm logging into a Debian box with key-pair authentiation (no password needed). The script needed to run will be different, so I don't want to put it into ~/.bashrc, I want to specify it on the command line when I login, something like:

ssh username@ip script_on_remote.sh

migrated from serverfault.com Apr 22 '13 at 13:15

This question came from our site for system and network administrators.

5

Your example is pretty much how you'd do it. You can specify the script using it's full path if it's not accessible on the $PATH.

# if scripts on the $PATH
ssh username@ip script_on_remote.sh

# if it's not on the path
ssh username@ip /path/to/my/script_on_remote.sh

# if it's including spaces
ssh username@ip "/path to my/script_on_remote.sh"
1

Specifying the command on the command line will work. You may have to put in the full path of the command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy