38 lines
1.6 KiB
Bash
38 lines
1.6 KiB
Bash
|
|
GITLAB_URL="git.ring-zero.co.uk"
|
|
#GITLAB_URL="192.168.1.195" # 192.168.1.48
|
|
GITLAB_PORT="443" # 10022:22 32768:443 10080:80
|
|
#GITLAB_PORT="32768" # 10022:22 32768:443 10080:80
|
|
#GITLAB_PORT="10080" # 10022:22 32768:443 10080:80
|
|
#GITLAB_PORT="10022" # 10022:22 32768:443 10080:80
|
|
GITLAB_USER="cyteen"
|
|
|
|
PROTO="https" # http
|
|
CURL_OPTIONS="--insecure" # accept self signed certificate
|
|
|
|
PRIVATE_TOKEN="ZAKBXqfs71k6iq7JkiyU" # ${PROTO}://${GITLAB_URL}/profile/personal_access_tokens //*[@id="feed_token"]
|
|
|
|
# Create with: ssh-keygen -t rsa -b 4096 -N '' -C "${LOCAL_USER_EMAIL}" -f ~/.ssh/gitlab_rsa or use existing pubkey
|
|
#RSA_KEY=$(cat ${HOME}/.ssh/gitlab_rsa.pub)
|
|
RSA_KEY=$(cat "${HOME}"/.ssh/id_rsa.pub)
|
|
|
|
# Send
|
|
echo ""
|
|
echo "Sending key."
|
|
echo "COMMAND: curl ${CURL_OPTIONS} -d '{"title":"test key","key":"'"${RSA_KEY}"'"}' -H 'Content-Type: application/json' ${PROTO}://${GITLAB_URL}:${GITLAB_PORT}/api/v4/user/keys?private_token=${PRIVATE_TOKEN}"
|
|
|
|
curl ${CURL_OPTIONS} -d '{"title":"test key","key":"'"${RSA_KEY}"'"}' -H 'Content-Type: application/json' ${PROTO}://${GITLAB_URL}:${GITLAB_PORT}/api/v4/user/keys?private_token=${PRIVATE_TOKEN}
|
|
|
|
# {"id":3889765,"title":"test key","key":"ssh-rsa <my_ssh_key>","created_at":"2019-08-01T21:26:40.952Z"}
|
|
|
|
|
|
|
|
# Test
|
|
echo ""
|
|
echo "Testing key."
|
|
echo "COMMAND: curl ${CURL_OPTIONS} ${PROTO}://${GITLAB_URL}:${GITLAB_PORT}/api/v4/user/keys?private_token=${PRIVATE_TOKEN}"
|
|
|
|
curl ${CURL_OPTIONS} ${PROTO}://${GITLAB_URL}:${GITLAB_PORT}/api/v4/user/keys?private_token=${PRIVATE_TOKEN}
|
|
|
|
# [{"id":3889765,"title":"test key","key":"ssh-rsa <my_ssh_key>","created_at":"2019-08-01T21:26:40.952Z"}]
|