Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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

share|improve this question

migrated from Apr 22 '13 at 13:15

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

2 Answers 2

up vote 5 down vote accepted

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

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

# if it's including spaces
ssh username@ip "/path to my/"
share|improve this answer

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.