0

A developer where I work has recently left, and I've been tasked with recycling all of our keys etc.

We use BitBucket for our source control and this particular developer has a "pull script" running on one of our servers that would pull anything from our development branch onto a test version of the site. After we removed his Atlassian account, it took the SSH key this deploy script used with it. I have since generated new keys, uploaded the public to my Atlassian account, and placed the private on the server, so far so good.

However his deploy script returns Permission denied (publickey).

When I try $ ssh [email protected] I get the following:

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.

Which appears to work? (Forgive my ignorance if this is not the case)

The deploy script is as follows:

<?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>

Source control is certainly not my forte and I see it as a necessary evil, I am assuming that the reason the script fails is that git on our server is either pointing to github rather than bitbucket, or still trying to use some of the previous developers credentials?

I have changed the git config --global user.name and git config --global user.email to try and combat this.

Any suggestions would be greatly appreciated.

4
  • Are you testing the SSH command with the same user that run the PHP script? Commented Jun 30, 2017 at 9:50
  • Ah perhaps not! I imagine the script is being ran by www-data Commented Jun 30, 2017 at 9:53
  • So I think you need to enable the SSH for the www-data user Commented Jun 30, 2017 at 9:59
  • I think you are probably right, I'll have a crack at it now, if it works I'll let you know, if you post an answer I will give you the rep ofc Commented Jun 30, 2017 at 10:02

1 Answer 1

1

The SSH key need to be available to the user running your PHP script.

So take a look at Generating SSH keys for 'apache' user and this answer.

BTW, user.email and user.name are for identification in commit data, authentication is done with SSH username and password, SSH key or HTTP authentication, with no relation to commit identification data.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.