![](/img/trans.png)
[英]SSH Connection gets refused when executing bash script within Node.js
[英]When executing an SSH command in Jenkins, the bash profile is different to when connecting over SSH with the same user
我正在嘗試使用Jenkins SSH exec功能在遠程服務器上運行一些CLI nodejs命令。
嘗試永久運行時,我收到一條錯誤消息,該消息是我在npm上全局安裝的。
編輯 :錯誤是; -bash: forever: command not found
。
以root身份通過SSH連接並運行which npm
返回;
/root/local/bin/npm
而通過Jenkins,以與root相同的命令返回;
/usr/bin/npm
我試過設置bash變量,但這些變量在兩種連接介質之間似乎也不一致。
兩者都使用此處詳細介紹的top方法安裝; https://gist.github.com/isaacs/579814#file-node-and-npm-in-30-seconds-sh
嘗試這個:
ssh user@host -t 'bash -l -c "forever"'
您可以和man ssh
一起閱讀:
如果指定了命令,那么它將在遠程主機而不是登錄shell上執行。
沒有login shell
沒有rc-files
( .bashrc
, .bash_profile
等),因此可能沒有您期望的$PATH
。
要了解有關登錄Shell的更多信息,請檢查man bash
並搜索-l
選項說明。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.