2017-06-30 95 views
0

我工作的地方最近离开的开发商,我一直在负责回收所有的按键等Git的部署脚本失败,但SSH并不

我们用到位桶为我们的源代码控制和这个特别的开发人员在我们的一台服务器上运行“pull脚本”,这会将我们的开发分支中的任何内容拖放到该站点的测试版本上。在我们删除了他的Atlassian帐户之后,它使用了与此密钥一起使用的SSH密钥。之后,我生成了新的密钥,将公众上传到我的Atlassian帐户,并将私人服务器放置在服务器上,非常好。

然而,他的部署脚本返回Permission denied (publickey).

当我尝试$ ssh [email protected]我得到如下:

PTY allocation request failed on channel 0 
logged in as ChocolateDinosaur. 

You can use git or hg to connect to Bitbucket. Shell access is disabled. 
Connection to bitbucket.org closed. 

这似乎工作? (请原谅我的无知,如果不是这种情况)

部署脚本如下:

<?php 
$commands = array(
    'echo $PWD', 
    'whoami', 
    'git pull', 
    'git status', 
    // 'git submodule sync', 
    // 'git submodule update', 
    // 'git submodule status', 
); 

$output = ''; 
foreach($commands AS $command){ 
    $tmp = shell_exec($command); 
    $output .= "<span style=\"color: #6BE234;\">\$</span> <span style=\"color: #729FCF;\">{$command}\n</span>"; 
    $output .= htmlentities(trim($tmp)) . "\n"; 
} 
?> 
<!DOCTYPE HTML> 
<html lang="en-US"> 
<head> 
    <meta charset="UTF-8"> 
    <title>GIT DEPLOYMENT SCRIPT</title> 
</head> 
<body style="background-color: #000000; color: #FFFFFF; font-weight: bold; padding: 0 10px;"> 

<pre> 
<?=$output?> 
</pre> 

</body> 
</html> 

源代码控制肯定不是我的强项,我认为这是一个必要的恶,我假设脚本失败的原因是我们的服务器上的git要么指向github而不是bitbucket,要么仍然试图使用一些以前的开发人员凭据?

我已经改变了git config --global user.namegit config --global user.email来试图解决这个问题。

任何建议将不胜感激。

+0

您是否正在使用运行PHP脚本的相同用户测试SSH命令? – zigarn

+0

啊也许不是!我想这个脚本是由www-data – Aphire

+0

运行的所以我认为你需要启用SSH的www数据用户 – zigarn

回答

1

SSH密钥需要运行PHP脚本的用户可用。

所以看看Generating SSH keys for 'apache' userthis answer

顺便说一下,user.emailuser.name用于在提交数据中进行标识,使用SSH用户名和密码,SSH密钥或HTTP身份验证进行身份验证,与提交标识数据无关。