bluenevus commited on
Commit
3795b36
·
verified ·
1 Parent(s): 1aa8e1f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -16,10 +16,11 @@ def fetch_github_file(github_url, ssh_private_key):
16
  ssh = paramiko.SSHClient()
17
  ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
18
 
19
- # Format the SSH key
20
- formatted_key = "-----BEGIN OPENSSH PRIVATE KEY-----\n"
21
- formatted_key += "\n".join(ssh_private_key.strip().split())
22
- formatted_key += "\n-----END OPENSSH PRIVATE KEY-----\n"
 
23
 
24
  # Load the private key
25
  private_key = paramiko.RSAKey.from_private_key(io.StringIO(formatted_key))
 
16
  ssh = paramiko.SSHClient()
17
  ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
18
 
19
+ # Clean and format the SSH key
20
+ ssh_private_key = '\n'.join(line.strip() for line in ssh_private_key.split('\n') if line.strip())
21
+ if not ssh_private_key.startswith("-----BEGIN"):
22
+ ssh_private_key = f"-----BEGIN OPENSSH PRIVATE KEY-----\n{ssh_private_key}\n-----END OPENSSH PRIVATE KEY-----"
23
+
24
 
25
  # Load the private key
26
  private_key = paramiko.RSAKey.from_private_key(io.StringIO(formatted_key))