How to use/run bash aliases over ssh based session?

To run a free command or date command with ssh:


$ ssh vyga@ucartz.com date

Sample outputs:

Tue Dec 26 09:02:50 UTC 2017


Understanding bash shall and command types

The bash shell understands the following types of commands:

  1. Aliases such as ll
  2. Keywords such as if
  3. Functions (user-defined functions such as genpasswd)
  4. Built in such as pwd
  5. Files such as /bin/date


Bash aliases not running or working over ssh client on Unix based system

To solve this problem run ssh command as follows:

$ ssh -t user@remote /bin/bash -ic 'your-alias-here'
$ ssh -t user@remote /bin/bash -ic 'file_repl'

In short run the following command to run bash alias called ll:

$ ssh -t vyga@ucartz.com -ic 'll'
Was this answer helpful? 0 Users Found This Useful (0 Votes)