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:
		@@ -269,6 +269,11 @@ def ssh_add_key(env, key):
 | 
				
			|||||||
    """
 | 
					    """
 | 
				
			||||||
        Adds an ssh key to the ssh-agent
 | 
					        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,
 | 
					    process = Popen(['ssh-add', '-'], stdin=PIPE, stdout=None,
 | 
				
			||||||
                    stderr=PIPE, env=env)
 | 
					                    stderr=PIPE, env=env)
 | 
				
			||||||
    (_, error) = process.communicate(input=str.encode(key))
 | 
					    (_, error) = process.communicate(input=str.encode(key))
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user