key string to file obj

This commit is contained in:
Nguyen Huu Thuong
2020-08-15 15:07:23 +02:00
parent 6c3c55657b
commit 06a4030088
2 changed files with 20 additions and 1 deletions

View File

@@ -34,6 +34,7 @@ jobs:
uses: cross-the-world/scp-pipeline@master
with:
host: ${{ secrets.DC_HOST }}
port: ${{ secrets.DC_PORT }}
user: ${{ secrets.DC_USER }}
pass: ${{ secrets.DC_PASS }}
local: "./test/test1*"
@@ -45,7 +46,20 @@ jobs:
TO_DIR: /home/github/test/test3/
with:
host: ${{ secrets.DC_HOST }}
port: ${{ secrets.DC_PORT }}
user: ${{ secrets.DC_USER }}
pass: ${{ secrets.DC_PASS }}
local: "."
remote: $TO_DIR
- name: local remote scp 3
uses: cross-the-world/scp-pipeline@master
env:
TO_DIR: /home/github/test/test3/
with:
host: ${{ secrets.DC_HOST }}
port: ${{ secrets.DC_PORT }}
user: ${{ secrets.DC_USER }}
key: ${{ secrets.DC_KEY }}
local: "."
remote: $TO_DIR

7
app.py
View File

@@ -6,6 +6,7 @@ import scp
import sys
import math
import re
import tempfile
envs = environ
@@ -47,7 +48,11 @@ def strip_and_parse_envs(p):
def connect():
ssh = paramiko.SSHClient()
p_key = paramiko.RSAKey.from_private_key(INPUT_KEY) if INPUT_KEY else None
p_key = None
if INPUT_KEY:
with tempfile.TemporaryFile() as fp:
fp.write(INPUT_KEY.encode())
p_key = paramiko.RSAKey.from_private_key(INPUT_KEY)
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(INPUT_HOST, port=INPUT_PORT, username=INPUT_USER,
pkey=p_key, password=INPUT_PASS,