mirror of
https://github.com/cross-the-world/scp-pipeline.git
synced 2025-09-10 03:29:52 +08:00
key string to file obj
This commit is contained in:
14
.github/workflows/deploy.yml
vendored
14
.github/workflows/deploy.yml
vendored
@@ -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
7
app.py
@@ -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,
|
||||
|
Reference in New Issue
Block a user