Skip to content

Commit 3b3bc30

Browse files
authored
Merge pull request #168 from ByteInternet/add-support-for-using-ssh-key-ed25519
Check for multiple paths for SSH keys like ~/.ssh/id_ed25519
2 parents e124265 + 456d102 commit 3b3bc30

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/Deployer/Task/Common/PrepareSshTaskGlobal.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,22 @@ class PrepareSshTaskGlobal extends TaskBase
1919
{
2020
private const BITBUCKET_KEY_PATH = '/opt/atlassian/pipelines/agent/ssh/id_rsa';
2121

22+
private const KEY_PATHS = [
23+
self::BITBUCKET_KEY_PATH,
24+
'~/.ssh/id_rsa',
25+
'~/.ssh/id_ed25519'
26+
];
27+
2228
public function configure(Configuration $config): void
2329
{
2430
set('ssh_key_file', function () {
25-
if (testLocally('[ -f ' . self::BITBUCKET_KEY_PATH . ' ]')) {
26-
return self::BITBUCKET_KEY_PATH;
31+
foreach (self::KEY_PATHS as $path) {
32+
if (testLocally("[ -f $path ]")) {
33+
return $path;
34+
}
2735
}
28-
return '~/.ssh/id_rsa';
36+
37+
return '~/.ssh/id_rsa'; // Fallback
2938
});
3039

3140
task('prepare:ssh', function () {

0 commit comments

Comments
 (0)