forked from linchpin/actions-wpengine-ssh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
64 lines (60 loc) · 1.81 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: 'Pressable SSH Setup'
description: 'Configures an SSH connection'
inputs:
ssh_user:
description: 'SSH Username'
required: true
ssh_key:
description: 'SSH Private key'
required: false
ssh_pass:
description: 'SSH Private key'
required: false
ssh_host:
description: 'SSH host'
required: true
runs:
using: 'composite'
steps:
- name: Auth SSH using Key
if: ${{ inputs.ssh_key }}
run: |
SSH_PATH="$HOME/.ssh"
KNOWN_HOSTS_PATH="$SSH_PATH/known_hosts"
SSH_KEY_PRIVATE_PATH="$SSH_PATH/github_action"
mkdir -p "$SSH_PATH"
mkdir -p "$SSH_PATH/ctl"
ssh-keyscan -t rsa "${{ inputs.ssh_host }}" >> "$KNOWN_HOSTS_PATH"
echo "${{ inputs.ssh_key }}" > "$SSH_KEY_PRIVATE_PATH"
chmod 700 "$SSH_PATH"
chmod 644 "$KNOWN_HOSTS_PATH"
chmod 600 "$SSH_KEY_PRIVATE_PATH"
cat >>~/.ssh/config <<END
Host pressable
HostName ${{ inputs.ssh_host }}
User ${{ inputs.ssh_user }}
IdentityFile $SSH_KEY_PRIVATE_PATH
StrictHostKeyChecking no
ControlMaster auto
ControlPath $SSH_PATH/ctl/%C
END
shell: bash
- name: Auth SSH using Pass
if: ${{ inputs.ssh_pass }}
run: |
SSH_PATH="$HOME/.ssh"
KNOWN_HOSTS_PATH="$SSH_PATH/known_hosts"
mkdir -p "$SSH_PATH"
mkdir -p "$SSH_PATH/ctl"
ssh-keyscan -t rsa "${{ inputs.ssh_host }}" >> "$KNOWN_HOSTS_PATH"
chmod 700 "$SSH_PATH"
chmod 644 "$KNOWN_HOSTS_PATH"
cat >>~/.ssh/config <<END
Host pressable
HostName ${{ inputs.ssh_host }}
User ${{ inputs.ssh_user }}
StrictHostKeyChecking no
ControlMaster auto
ControlPath $SSH_PATH/ctl/%C
END
shell: bash