-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (58 loc) · 1.84 KB
/
configure_ssh.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
65
name: Configure SSH
on: [workflow_dispatch]
jobs:
SSH_Configuration:
runs-on: ubuntu-latest
env:
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
LOCAL_PATH: ${{ secrets.LOCAL_PATH }}
REMOTE_PATH: ${{ secrets.REMOTE_PATH }}
SSH_KEY: ${{ secrets.REMOTE_KEY }}
steps:
- name: Checkout Repository
uses: actions/[email protected]
- name: Configure SSH
run: |
mkdir -p ~/.ssh/
echo "Printing environment variables"
echo $REMOTE_USER
echo $REMOTE_HOST
echo $LOCAL_PATH
echo $REMOTE_PATH
echo "${{ env.SSH_KEY }}" | tr -d '\r' > ~/.ssh/remote_key
echo ""
echo "Checking permissions of remote_key before"
ls -l ~/.ssh/remote_key
echo "Changing permissions of remote_key"
chmod 600 ~/.ssh/remote_key
echo "Checking permissions of remote_key after the change"
ls -l ~/.ssh/remote_key
#ssh-keyscan -H "${{ env.REMOTE_HOST }}" >> ~/.ssh/known_hosts
cat >>~/.ssh/config <<END
Host test_env
HostName $REMOTE_HOST
User $REMOTE_USER
IdentityFile ~/.ssh/remote_key
StrictHostKeyChecking no
END
echo "Checking contents of SSH configuration file"
echo "---"
cat ~/.ssh/config
echo "---"
echo "SSH configuration completed successfully."
ls -la ~/.ssh/
#cat ~/.ssh/known_hosts
- name: Test SSH Connection
#if: ${{ !env.ACT }}
run: |
echo "Testing SSH Connection"
ssh -tt test_env << 'EOF'
pwd
ls -la
cd ..
ls -la
cd /var/www/compare/
ls -la
exit
EOF