I have an alias defined in my
alias l.='ls -d .* --color=auto'
It's very useful :) but it doesn't work via
$ ssh localhost l. bash: l.: command not found
Why is that?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
ssh localhost -t bash -ci l.
The alias should be in
~/.bashrc on the remote server, not on your local machine.
-i option tells
bash to run an interactive shell. Aliases are enabled by default only in interactive shells.
-t options tells
ssh to allocate a pseudo-tty. Without this,
bash emits a warning message when started in interactive mode. This also enables
ls colors. Without it, you'd have to use
There is another way to enable aliases, without setting the interactive flag, namely
shopt -s expand_aliases. So you could try:
ssh localhost 'bash -c "shopt -s expand_aliases; l."'
.bashrc might only define aliases if the shell sourcing it is interactive. In this example, the shell would not be interactive at that time.
If you try to define aliases on the same line, see this.