Skip to content

Commit

Permalink
fix(ingest): add trailing newline to ssh keys (#5947)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsheth2 authored Sep 15, 2022
1 parent 1487377 commit 6698533
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,20 @@ def clone(self, ssh_key: SecretStr, repo_url: str) -> Path:
dirs_to_create = [keys_dir, checkout_dir]
for d in dirs_to_create:
os.makedirs(d, exist_ok=True)

# Write the SSH key to a file.
git_ssh_identity_file = os.path.join(keys_dir, "ssh_key")
with open(
git_ssh_identity_file,
"w",
opener=lambda path, flags: os.open(path, flags, 0o600),
) as fp:
fp.write(ssh_key.get_secret_value())
# SSH keys must have a trailing newline. Multiple newlines are fine,
# so we can just add one unconditionally.
fp.write("\n")

# Clone the repo using the ssh key.
git_ssh_cmd = f"ssh -i {git_ssh_identity_file}"
if self.skip_known_host_verification:
# Without this, the ssh command will prompt for confirmation of the host key.
Expand Down

0 comments on commit 6698533

Please sign in to comment.