cdzktg
Last Updated: February 25, 2016
·
20.88K
· sheerun
Photo on 08.01.2013 at 04.15

Run one command through ssh connection and exit

Simply enough you just have to append command to ssh:

ssh admin@example.com ps -eaf

3 Responses
Add your response

13868
70942ffdd8084b5a51e17e3c0996d53c

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

over 1 year ago ·
15921

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 ·
22262
None

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 ·