通过SSH连接到服务器时,可以从GitHub中拉出,但无法在运行时拉出
ssh $SERVER bash $REMOTE_SCRIPT_PATH
在本地。
本地密钥被添加到服务器和GitHub上,但是本地计算机对GitHub的密钥与服务器不同。不过,两者都被授予访问权限。
与在ssh user@ip
之后手动键入git命令并告诉SSH在远程服务器上运行bash脚本有什么不同?还是我在这里想念什么?
local_script.sh
SERVER=user@ip
REMOTE_SCRIPT_PATH=/home/user/remote_script.sh
function run()
{
echo "Running: $@"
"$@"
}
echo "---- Running deployment script on remote server ----"
run ssh $SERVER bash $REMOTE_SCRIPT_PATH
remote_script.sh
APP_DIR=/home/user/gitfolder
echo "---- Remote script ----"
cd $APP_DIR/
git pull
终端
$ ./local_script.sh
---- Running deployment script on remote server ----
Running: ssh user@ip bash /home/user/remote_script.sh
---- Remote script ----
+ cd /home/user/
+ git pull git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.
如果我通过SSH连接到服务器,只需键入“ git pull”,一切正常。
答案 0 :(得分:0)
您的服务器配置文件中可能有一些与ssh相关的配置, 所以请检查:
$HOME/.profile
$HOME/.bash_profile
例如,此变量:GIT_SSH_COMMAND