A working answer was published in SO, quoted below:
Quoted from the man page of
bash: Aliases are not expanded when
the shell is not interactive, unless the expand_aliases shell option
is set using shopt ...
So the simplest way IMO is to put the following lines at the top of
# comment out the original line
# [ -z "$PS1" ] && return
if [ -z "$PS1" ]; then
shopt -s expand_aliases
# alias ls='ls --color=always'
Save and exit. Now you can run
ssh user@host "your_alias"
Note: If your
~/.bashrc hold something like the below, comment the line that
return when the shell is not interactive:
# If not running interactively, don't do anything
case $- in