Last Updated: February 25, 2016
· sheerun

Run one command through ssh connection and exit

Simply enough you just have to append command to ssh:

ssh ps -eaf

3 Responses
Add your response


in this case /bin/bash doesn't do its full "login" procedure. do you know how to fix it?

over 1 year ago ·

Yes. .bash_profile will be sourced in a terminal session; .bashrc is run in a shell. Anything that needs to get executed for your one-liner needs to be in .bashrc.

over 1 year ago ·

and you can chain remote commands with ";"? or will those be treated as local shell commands as opposed to commands to run via SSH? i.e. the question is what if you wanted to run a set of commands thru SSH in a single line (as opposed to multiple SSH calls or putting everything in a shell script and running that script as command with SSH).

over 1 year ago ·