Refactoring Code
This commit is contained in:
18
src/commands/ssh/keys/retrieve.sh
Normal file
18
src/commands/ssh/keys/retrieve.sh
Normal file
@@ -0,0 +1,18 @@
|
||||
wxi-ssh-keys-retrieve(){
|
||||
wxi-header "SSH / Keys / Retrieve"
|
||||
wxi-restricted
|
||||
|
||||
if [[ ! -z $1 ]]
|
||||
then
|
||||
VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/keys/$1 -X GET --header "X-Vault-Token: $VAULT_TOKEN")
|
||||
if [[ $VAULT_STATUS -eq 200 ]]
|
||||
then
|
||||
echo $(curl https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/keys/$1 -X GET --header "X-Vault-Token: $VAULT_TOKEN" -s | jq -r '.data.data.private') | base64 -d > ~/.ssh/keys/$1 2>&1
|
||||
chmod 700 ~/.ssh/keys/$1
|
||||
echo $(curl https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/keys/$1 -X GET --header "X-Vault-Token: $VAULT_TOKEN" -s | jq -r '.data.data.public') | base64 -d > ~/.ssh/keys/$1.pub 2>&1
|
||||
chmod 700 ~/.ssh/keys/$1.pub
|
||||
fi
|
||||
fi
|
||||
|
||||
wxi-footer
|
||||
}
|
||||
Reference in New Issue
Block a user