Plink在连接时不提供bashrc或bash_profile

查尔斯:

我正在尝试将plink用作Windows上的ssh替代方法,但是我发现当plink连接到远程linux计算机时,它不源.bash_profile或.bashrc。
我应该创建其他点文件吗?还是还有其他选择?

例如,我的bashrc文件将目录添加到我的路径。该目录包含我要使用的其他程序,其中一个是python。

这将不起作用:

plink host python

在哪里:

plink host "source .bashrc;python"

当我使用不带命令参数的plink时,它会输出.bash_profile,并且一切正常,但是看来仅通过发送命令plink不会提供任何一个文件。

有解决方法吗?

Kurt Pfeifle:

如果仅通过ssh或plink连接到远程主机,它将启动登录帐户的默认Shell。如果该shell是bash,bash将自动获取.bash_profile。

如果您通过ssh或plink连接到远程主机,要求执行命令,则ssh将尝试仅执行该命令。

您可以通过使用ForcedCommand来实现另请参阅此处:

将强制命令设置为执行以下两项操作的脚本:

  1. 源.bash_profile
  2. 运行原始命令(环境变量$ SSH_ORIGINAL_COMMAND或$ SSH2_ORIGINAL_COMMAND)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

为什么$ GOPATH通常设置在〜/ .bashrc和〜/ .bash_profile中而不是〜/ .profile中?

在Linux中,“ bash”命令何时会提供〜/ .bash_profile或〜/ .profile文件?

从zsh进入bash时如何加载〜/ .bash_profile?

'\ r':找不到命令-.bashrc / .bash_profile

〜/ .profile,〜/ .bashrc和〜/ .bash_profile在新终端上未运行

VSCode集成终端不加载.bashrc或.bash_profile

〜/ .profile,〜/ .bashrc,〜/ .bash_profile,〜/ .gnomerc,/ etc / bash_bashrc,/ etc / screenrc ...之间有什么区别?

bash_profile或bashrc中的环境变量?

如何在外壳中向.bash_profile / .profile / bashrc添加功能?

为什么在.bashrc / .bash_profile中没有shebang?

为什么打开终端时不提供.profile文件?

使用SSH时,不会读取该服务器上的.bashrc别名,即使很难在.bash_profile和.bashrc中设置该别名

是bashrc还是bash_profile?

iTerm / zsh无法读取.bashrc或.bash_profile

Bash_profile代码

为什么Mac iterm和iterm2不提供.bashrc或.bash_profile?

.bashrc / .bash_profile未加载导出

全球bash_profile

从终端(fedora)以root用户登录时,为什么要更改用户?为什么我对.bashrc和.bash_profile所做的更改不显示?

从.bashrc启动tmux时,.profile和.bash_profile被忽略了吗?

.bashrc和.bash_profile之间的区别

不提供bash_profile或不回显语句

使用`sudo su-username -c`时无法从.bash_profile中获取.bashrc。

尽管.bashrc源于Mac / iTerm2上的.bash_profile和.profile,但仍未运行

使 Windows Git Bash 终端查找 .bashrc 和 .bash_profile 的自定义位置

在终端会话中激活别名而不使用 bashrc 或 bash_profile 或 bash_aliases?

使用 .bash_profile 和 .bashrc 作为一个

从 bashrc 或 bash_profile 加载变量不起作用

将 bashrc 文件添加到 bash_profile