Ensure SSH key ends with newline
In at least some versions of the 'ssh-add' command, adding a SSH key requires that SSH key is newline terminated. If it is not, ssh-add doesn't add the key and, instead, unhelpfully prompts for a passphrase for the key ('Enter passphrase for (stdin):'). This change makes sure the key is terminated with a newline character to hopefully avoid this issue occurring as often. Signed-off-by: Sam Lewis <sam.vr.lewis@gmail.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
parent
a5d0153e84
commit
b5ba370049
@ -269,6 +269,11 @@ def ssh_add_key(env, key):
|
||||
"""
|
||||
Adds an ssh key to the ssh-agent
|
||||
"""
|
||||
# The ssh-agent needs the key to end with a newline, otherwise it
|
||||
# unhelpfully prompts for a password
|
||||
if not key.endswith('\n'):
|
||||
key += '\n'
|
||||
|
||||
process = Popen(['ssh-add', '-'], stdin=PIPE, stdout=None,
|
||||
stderr=PIPE, env=env)
|
||||
(_, error) = process.communicate(input=str.encode(key))
|
||||
|
Loading…
Reference in New Issue
Block a user