forked from dokku-alt/dokku-alt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost-deploy
More file actions
executable file
·44 lines (33 loc) · 1.17 KB
/
Copy pathpost-deploy
File metadata and controls
executable file
·44 lines (33 loc) · 1.17 KB
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
#!/bin/bash
REMOTE=$1
REPO=$2
set -xe
echo Generate new ssh key...
ssh-keygen -q -t rsa -N "" -f test_rsa
FINGERPRINT=$(ssh-keygen -lf "test_rsa.pub" | awk '{print $2}')
echo Try to access any dokku command using admin key
ssh $REMOTE access:add < test_rsa.pub
./ssh-test $REMOTE version
echo List admins
./ssh-test $REMOTE access:list
echo Revoke admin permission
./ssh-test $REMOTE access:remove $FINGERPRINT
./ssh-test $REMOTE version && exit 1
echo Try to access any dokku command using deploy key
ssh $REMOTE deploy:allow $REPO < test_rsa.pub
./ssh-test $REMOTE version && exit 1
echo Try to push to non-existing repository as deploy we have no access
export GIT_SSH="./ssh-test"
git remote add new-target $REMOTE:$REPO-other
git push new-target master && exit 1
echo Create new repository and push once-again
ssh $REMOTE create $REPO-other
ssh $REMOTE deploy:allow $REPO-other < test_rsa.pub
git push new-target master
echo Try to revoke permission
ssh $REMOTE deploy:revoke $REPO-other $FINGERPRINT
git push new-target master && exit 1
echo Try to upgrade deploy key
ssh $REMOTE deploy:allow $REPO-other < test_rsa.pub
ssh $REMOTE access:add < test_rsa.pub
./ssh-test $REMOTE version