|
1 |
| -# Copyright (C) 2018-2019 Intel Corporation |
| 1 | +# Copyright (C) 2018-2020 Intel Corporation |
2 | 2 | #
|
3 | 3 | # SPDX-License-Identifier: MIT
|
4 | 4 |
|
@@ -50,10 +50,22 @@ def generate_ssh_keys():
|
50 | 50 | ssh_dir = '{}/.ssh'.format(os.getenv('HOME'))
|
51 | 51 | pidfile = os.path.join(ssh_dir, 'ssh.pid')
|
52 | 52 |
|
| 53 | + def add_ssh_keys(): |
| 54 | + IGNORE_FILES = ('README.md', 'ssh.pid') |
| 55 | + keys_to_add = [entry.name for entry in os.scandir(ssh_dir) if entry.name not in IGNORE_FILES] |
| 56 | + keys_to_add = ' '.join(os.path.join(ssh_dir, f) for f in keys_to_add) |
| 57 | + subprocess.run(['ssh-add {}'.format(keys_to_add)], |
| 58 | + shell = True, |
| 59 | + stderr = subprocess.PIPE, |
| 60 | + # lets set the timeout if ssh-add requires a input passphrase for key |
| 61 | + # otherwise the process will be freezed |
| 62 | + timeout=30, |
| 63 | + ) |
| 64 | + |
53 | 65 | with open(pidfile, "w") as pid:
|
54 | 66 | fcntl.flock(pid, fcntl.LOCK_EX)
|
55 | 67 | try:
|
56 |
| - subprocess.run(['ssh-add {}/*'.format(ssh_dir)], shell = True, stderr = subprocess.PIPE) |
| 68 | + add_ssh_keys() |
57 | 69 | keys = subprocess.run(['ssh-add -l'], shell = True,
|
58 | 70 | stdout = subprocess.PIPE).stdout.decode('utf-8').split('\n')
|
59 | 71 | if 'has no identities' in keys[0]:
|
@@ -440,3 +452,4 @@ def generate_ssh_keys():
|
440 | 452 | }
|
441 | 453 |
|
442 | 454 | USE_CACHE = True
|
| 455 | + |
0 commit comments