Skip to content

Commit

Permalink
check for all ssh key headers
Browse files Browse the repository at this point in the history
  • Loading branch information
diivi committed Feb 24, 2023
1 parent fe6fb5e commit 08cef65
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/vorta/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,10 @@ def choose_file_dialog(parent, title, want_folder=True):

def is_ssh_file(filepath: str) -> bool:
"""Check if the file is a SSH key."""
with open(filepath, 'rb') as f:
with open(filepath, 'r') as f:
first_line = f.readline()
if not first_line.startswith(b'-----BEGIN OPENSSH PRIVATE KEY-----'):
return False
return True
pattern = r'^-----BEGIN(\s\w+)? PRIVATE KEY-----'
return re.match(pattern, first_line) is not None


def get_private_keys() -> List[str]:
Expand Down

0 comments on commit 08cef65

Please sign in to comment.