Skip to content

Commit 677872d

Browse files
piterpunkdwoz
authored andcommitted
Allows characters . and @ in SSH keys regexp
1 parent b8180fc commit 677872d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

salt/states/ssh_auth.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def _present_test(
9898
)
9999
else:
100100
# check if this is of form {options} {enc} {key} {comment}
101-
sshre = re.compile(r"^(.*?)\s?((?:sk-)?(?:ssh\-|ecds)[\w-]+\s.+)$")
101+
sshre = re.compile(r"^(.*?)\s?((?:sk-)?(?:ssh\-|ecds)[\w@.-]+\s.+)$")
102102
fullkey = sshre.search(name)
103103
# if it is {key} [comment]
104104
if not fullkey:
@@ -171,7 +171,7 @@ def _absent_test(
171171
return (True, f"All host keys in file {source} are already absent")
172172
else:
173173
# check if this is of form {options} {enc} {key} {comment}
174-
sshre = re.compile(r"^(.*?)\s?((?:sk-)?(?:ssh\-|ecds)[\w-]+\s.+)$")
174+
sshre = re.compile(r"^(.*?)\s?((?:sk-)?(?:ssh\-|ecds)[\w@.-]+\s.+)$")
175175
fullkey = sshre.search(name)
176176
# if it is {key} [comment]
177177
if not fullkey:
@@ -268,7 +268,7 @@ def present(
268268

269269
if source == "":
270270
# check if this is of form {options} {enc} {key} {comment}
271-
sshre = re.compile(r"^(.*?)\s?((?:sk-)?(?:ssh\-|ecds)[\w-]+\s.+)$")
271+
sshre = re.compile(r"^(.*?)\s?((?:sk-)?(?:ssh\-|ecds)[\w@.-]+\s.+)$")
272272
fullkey = sshre.search(name)
273273
# if it is {key} [comment]
274274
if not fullkey:
@@ -482,7 +482,7 @@ def absent(
482482
)
483483
else:
484484
# Get just the key
485-
sshre = re.compile(r"^(.*?)\s?((?:sk-)?(?:ssh\-|ecds)[\w-]+\s.+)$")
485+
sshre = re.compile(r"^(.*?)\s?((?:sk-)?(?:ssh\-|ecds)[\w@.-]+\s.+)$")
486486
fullkey = sshre.search(name)
487487
# if it is {key} [comment]
488488
if not fullkey:

0 commit comments

Comments
 (0)