Find ssh keys in other types then RSA.
In case user doesn't have either ~/.ssh/id_rsa or didn't provide key through the commandline or config file, the boxpy will complain about missing ssh key. With this commit all default supported types of ssh keys are checked prior to parsing commandline/configuration, and first one will be selected. The order of the key types is described in manual for ssh-keygen.
This commit is contained in:
1 parent
e3ae80244b
commit
b9f2bc1846
2 files changed
+17
-4
No files matched your search
@@ -18,7 +18,7 @@ import requests
|
||||
import yaml
|
||||
|
||||
|
||||
__version__ = "1.11.3"
|
||||
__version__ = "1.11.6"
|
||||
|
||||
CACHE_DIR = os.environ.get('XDG_CACHE_HOME', os.path.expanduser('~/.cache'))
|
||||
CLOUD_IMAGE = "ci.iso"
|
||||
@@ -46,7 +46,6 @@ ssh:
|
||||
boxpy_data:
|
||||
cpus: 1
|
||||
disk_size: 6144
|
||||
key: ~/.ssh/id_rsa
|
||||
memory: 1024
|
||||
'''
|
||||
COMPLETIONS = {'bash': '''\
|
||||
@@ -542,10 +541,24 @@ class Config:
|
||||
self.ssh_key_path = os.path.join(os.path.expanduser("~/.ssh"),
|
||||
self.ssh_key_path)
|
||||
if not os.path.exists(self.ssh_key_path):
|
||||
raise BoxConfError(f'Cannot find ssh public key: {self.key}')
|
||||
if self.key:
|
||||
raise BoxConfError(f"Cannot find ssh public key: '{self.key}'")
|
||||
else:
|
||||
raise BoxConfError(f"Cannot find any default ssh public key")
|
||||
|
||||
def _set_defaults(self):
|
||||
conf = yaml.safe_load(USER_DATA)
|
||||
conf['boxpy_data']['key'] = ''
|
||||
# find out if there are SSH keys already. Set the first key found
|
||||
for key in ['id_ecdsa', 'id_ecdsa_sk', 'id_ed25519', 'id_ed25519_sk',
|
||||
'id_mldsa44_ed25519', 'id_rsa']:
|
||||
if os.path.exists(os.path
|
||||
.join(os.path
|
||||
.expanduser('~/.ssh'), key)):
|
||||
conf['boxpy_data']['key'] = key
|
||||
break
|
||||
else:
|
||||
LOG.warning("There is no usable default key found in ~/.ssh")
|
||||
|
||||
# update attributes with default values
|
||||
for key, val in conf['boxpy_data'].items():
|
||||
|
||||
Reference in new issue
Block a user