Skip to content

Commit 6f41519

Browse files
committed
Accept more ssh key types
1 parent 1e4206f commit 6f41519

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

linode_api4/common.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import os
44

55

6+
SSH_KEY_TYPES = ("ssh-dss", "ssh-rsa", "ssh-ed25519", "ecdsa-sha2-nistp256",
7+
"ecdsa-sha2-nistp384", "ecdsa-sha2-nistp521")
8+
9+
610
def load_and_validate_keys(authorized_keys):
711
"""
812
Loads authorized_keys as taken by :any:`instance_create`,

linode_api4/linode_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from linode_api4.objects import *
1212
from linode_api4.objects.filtering import Filter
1313

14-
from .common import load_and_validate_keys
14+
from .common import load_and_validate_keys, SSH_KEY_TYPES
1515
from .paginated_list import PaginatedList
1616

1717
package_version = pkg_resources.require("linode_api4")[0].version
@@ -406,13 +406,13 @@ def ssh_key_upload(self, key, label):
406406
:raises ValueError: If the key provided does not appear to be valid, and
407407
does not appear to be a path to a valid key.
408408
"""
409-
if not key.startswith('ssh-rsa'):
409+
if not key.startswith(SSH_KEY_TYPES):
410410
# this might be a file path - look for it
411411
path = os.path.expanduser(key)
412412
if os.path.isfile(path):
413413
with open(path) as f:
414414
key = f.read().strip()
415-
if not key.startswith('ssh-rsa'):
415+
if not key.startswith(SSH_KEY_TYPES):
416416
raise ValueError('Invalid SSH Public Key')
417417

418418
params = {

0 commit comments

Comments
 (0)