问题原文
原帖链接 · intrixius · CC BY-SA 3.0
When I ssh into a server (4.3.3-2-ARCH), my .bashrc is not loaded (however, I can load it manually by sourcing it).
I don't have any other files in my home folder, like .profile. The shell is also correct
$ echo $SHELL
/bin/bash
When I login using ssh -t myserver /bin/bash , my .bashrc IS loaded correctly.
In SSH verbose mode, I do see that /etc/bash.bashrc and ~/.bashrc are loaded using the last command. When using the default ssh command, none of them is being loaded...
What should I configure to have .bashrc (and /etc/bash.bashrc) loaded when using the default ssh command?
已采纳解答
原帖链接 · user9517 · CC BY-SA 3.0
the ~/.bashrc file is loaded for interactive non-login shells, that's why running /bin/bash from ssh works as you expect.
For login shells (amongst others) ~/.bash_profile is read. Typically your ~/.bash_profile contains something like
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
Which ensures that ~/.bashrc is loaded if your shell is a login shell.
If your ~/.bash_profile contains the above and ~/.bashrc is not being loaded you can debug the scripts by using set -x as usual.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
