自動 ssh 和 screen - 我錯過了什麼?

自動 ssh 和 screen - 我錯過了什麼?

這工作正常,但不會~/.bash_profile在 server2 上加載我的。為什麼?

$ ssh -A -t server1 ssh -A -t server2 bash -c "screen -dR"

答案1

bash man頁面:

When an interactive shell that is not a login shell  is  started,  bash
reads  and  executes  commands  from /etc/bash.bashrc and ~/.bashrc, if
these files exist.  This may be inhibited by using the  --norc  option.
The  --rcfile  file option will force bash to read and execute commands
from file instead of /etc/bash.bashrc and ~/.bashrc.

您可以重新附加到正在執行的現有會話screen(可能已經在執行bash),這不需要登入 shell。或者您screen使用新的互動式非登入 shell 建立一個新會話。僅登入 shell 進程.bash_profile

bash在命令列上指定的啟動screen命令是完全不同的呼叫。

相關內容