Sample Header Ad - 728x90

Run a command in an interactive shell with ssh after sourcing .bashrc

20 votes
2 answers
41841 views
I want to ssh into a remote Ubuntu computer, source my .bashrc and run a command that depends on parameters set by that .bashrc. All that in an interactive shell that doesn't close after the command is done. What I tried until now is ssh user@remote_computer -t 'bash -l -c "my_alias;bash"' or just ssh user@remote_computer -t "my_alias;bash" This works for general commands (like ls for example) but when I try to run an alias defined in .bashrc I get an error: bash: my_alias: command not found But then when I write it manually again and run it, it works! So how can I make sure the the .bashrc is sourced before the command is called?
Asked by Mehdi (422 rep)
Nov 18, 2015, 11:09 AM
Last activity: Apr 8, 2025, 03:00 PM