Compare commits
No commits in common. "399372294cdf9800832f32a798ccc02f95be0e14" and "2df1590a6dbe57beb7ee1ba3c051ef3dbc5e3005" have entirely different histories.
399372294c
...
2df1590a6d
@ -5,11 +5,4 @@
|
|||||||
mkdir $HOME/bin &> /dev/null
|
mkdir $HOME/bin &> /dev/null
|
||||||
curl https://git.waren.io/warengroup/wx/raw/branch/master/wx -o $HOME/bin/wx &> /dev/null
|
curl https://git.waren.io/warengroup/wx/raw/branch/master/wx -o $HOME/bin/wx &> /dev/null
|
||||||
chmod +x $HOME/bin/wx &> /dev/null
|
chmod +x $HOME/bin/wx &> /dev/null
|
||||||
export PATH=$HOME/bin:$PATH
|
|
||||||
```
|
|
||||||
|
|
||||||
## Schedule
|
|
||||||
```
|
|
||||||
# Warén CLI
|
|
||||||
*/30 * * * * $HOME/bin/wx auto
|
|
||||||
```
|
```
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
wx-auto(){
|
|
||||||
wx-ssh-config-sync
|
|
||||||
wx-ssh-keys-sync
|
|
||||||
wx-ssh-sign
|
|
||||||
}
|
|
@ -8,22 +8,11 @@ Usage: $0 COMMAND [OPTIONS]
|
|||||||
|
|
||||||
Common Commands:
|
Common Commands:
|
||||||
init Init
|
init Init
|
||||||
help Help
|
|
||||||
ssh SSH
|
ssh SSH
|
||||||
config Config
|
config Config
|
||||||
edit Edit
|
|
||||||
save Save
|
|
||||||
sync Sync
|
|
||||||
keys Keys
|
|
||||||
generate Generate
|
|
||||||
delete Delete
|
|
||||||
save Save
|
|
||||||
sync Sync
|
|
||||||
sign Certificates
|
sign Certificates
|
||||||
|
|
||||||
Management Commands:
|
Management Commands:
|
||||||
auto Auto
|
|
||||||
login Login
|
|
||||||
settings Settings
|
settings Settings
|
||||||
";
|
";
|
||||||
|
|
||||||
|
@ -5,8 +5,6 @@ wx-infra(){
|
|||||||
echo " >> Infra << "
|
echo " >> Infra << "
|
||||||
echo "------------------------------"
|
echo "------------------------------"
|
||||||
|
|
||||||
INFRA_PATH="/home/cwchristerw/Desktop/Work in Progress/Programming/warengroup/infra"
|
|
||||||
|
|
||||||
case $USER in
|
case $USER in
|
||||||
cwchristerw)
|
cwchristerw)
|
||||||
if [[ -z $1 ]]
|
if [[ -z $1 ]]
|
||||||
@ -19,12 +17,12 @@ wx-infra(){
|
|||||||
then
|
then
|
||||||
echo "Tag Required"
|
echo "Tag Required"
|
||||||
else
|
else
|
||||||
cd "$INFRA_PATH"
|
cd "/home/cwchristerw/Desktop/Work in Progress/Programming/warengroup/infra"
|
||||||
ansible-playbook --vault-id warengroup@vault/warengroup playbooks/init.yml -t $2 $3 $4 $5 $6 $7 $8 $9
|
ansible-playbook --vault-id warengroup@vault/warengroup playbooks/init.yml -t $2 $3 $4 $5 $6 $7 $8 $9
|
||||||
cd "$OLDPWD"
|
cd "$OLDPWD"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
cd "$INFRA_PATH"
|
cd "/home/cwchristerw/Desktop/Work in Progress/Programming/warengroup/infra"
|
||||||
ansible-playbook --vault-id warengroup@vault/warengroup playbooks.yml -t $1 $2 $3 $4 $5 $6 $7 $8 $9
|
ansible-playbook --vault-id warengroup@vault/warengroup playbooks.yml -t $1 $2 $3 $4 $5 $6 $7 $8 $9
|
||||||
cd "$OLDPWD"
|
cd "$OLDPWD"
|
||||||
fi
|
fi
|
||||||
|
@ -5,9 +5,6 @@ wx-ssh(){
|
|||||||
sign)
|
sign)
|
||||||
wx-ssh-sign
|
wx-ssh-sign
|
||||||
;;
|
;;
|
||||||
keys)
|
|
||||||
wx-ssh-keys $2 $3
|
|
||||||
;;
|
|
||||||
config)
|
config)
|
||||||
wx-ssh-config $2
|
wx-ssh-config $2
|
||||||
;;
|
;;
|
||||||
|
@ -19,6 +19,8 @@ wx-ssh-config(){
|
|||||||
wx-stop
|
wx-stop
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-config-edit(){
|
wx-ssh-config-edit(){
|
||||||
@ -26,15 +28,9 @@ wx-ssh-config-edit(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-config-save(){
|
wx-ssh-config-save(){
|
||||||
curl https://$VAULT_DOMAIN/v1/cli/data/$USER/settings/ssh/config -X POST --header "X-Vault-Token: ${config["login",$ORG]}" -d "{ \"data\": { \"data\": \"$(cat ~/.ssh/config | base64 -w 0)\" } }" -s &> /dev/null
|
curl https://$VAULT_DOMAIN/v1/cli/data/$USER -X POST --header "X-Vault-Token: ${config["login",$ORG]}" -d "{ \"data\": { \"settings/ssh/config\": \"$(cat ~/.ssh/config | base64 -w 0)\" } }" -s &> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-config-sync(){
|
wx-ssh-config-sync(){
|
||||||
VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/cli/data/$USER/settings/ssh/config -X GET --header "X-Vault-Token: ${config["login",$ORG]}")
|
echo $(curl https://$VAULT_DOMAIN/v1/cli/data/$USER -X GET --header "X-Vault-Token: ${config["login",$ORG]}" -s | jq -r '.data.data["settings/ssh/config"]') | base64 -d > ~/.ssh/config 2>&1
|
||||||
if [[ $VAULT_STATUS -eq 200 ]]
|
|
||||||
then
|
|
||||||
echo $(curl https://$VAULT_DOMAIN/v1/cli/data/$USER/settings/ssh/config -X GET --header "X-Vault-Token: ${config["login",$ORG]}" -s | jq -r '.data.data.data') | base64 -d > ~/.ssh/config 2>&1
|
|
||||||
else
|
|
||||||
echo "Status: Config Required"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
wx-ssh-keys(){
|
|
||||||
echo " >> SSH / Keys << "
|
|
||||||
echo "------------------------------"
|
|
||||||
|
|
||||||
case $1 in
|
|
||||||
generate)
|
|
||||||
wx-ssh-keys-sync $2
|
|
||||||
wx-ssh-keys-generate $2
|
|
||||||
wx-ssh-config-save $2
|
|
||||||
;;
|
|
||||||
retrieve)
|
|
||||||
wx-ssh-keys-retrieve $2
|
|
||||||
;;
|
|
||||||
save)
|
|
||||||
wx-ssh-keys-save $2
|
|
||||||
;;
|
|
||||||
sync)
|
|
||||||
wx-ssh-keys-sync $2
|
|
||||||
;;
|
|
||||||
delete)
|
|
||||||
wx-ssh-keys-remove $2
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
wx-ssh-keys-sync
|
|
||||||
wx-stop
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
wx-ssh-keys-generate(){
|
|
||||||
if [[ ! -z $1 ]]
|
|
||||||
then
|
|
||||||
if [[ ! -f "$HOME/.ssh/keys/$1" ]]
|
|
||||||
then
|
|
||||||
ssh-keygen -t ed25519 -f $HOME/.ssh/keys/$1 -q -N "" -C "$USER" &> /dev/null
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
wx-ssh-keys-retrieve(){
|
|
||||||
if [[ ! -z $1 ]]
|
|
||||||
then
|
|
||||||
VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/cli/data/$USER/settings/ssh/keys/$1 -X GET --header "X-Vault-Token: ${config["login",$ORG]}")
|
|
||||||
if [[ $VAULT_STATUS -eq 200 ]]
|
|
||||||
then
|
|
||||||
echo $(curl https://$VAULT_DOMAIN/v1/cli/data/$USER/settings/ssh/keys/$1 -X GET --header "X-Vault-Token: ${config["login",$ORG]}" -s | jq -r '.data.data.private') | base64 -d > ~/.ssh/keys/$1 2>&1
|
|
||||||
echo $(curl https://$VAULT_DOMAIN/v1/cli/data/$USER/settings/ssh/keys/$1 -X GET --header "X-Vault-Token: ${config["login",$ORG]}" -s | jq -r '.data.data.public') | base64 -d > ~/.ssh/keys/$1.pub 2>&1
|
|
||||||
else
|
|
||||||
echo "Status: Key Required"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
wx-ssh-keys-save(){
|
|
||||||
if [[ ! -z $1 ]]
|
|
||||||
then
|
|
||||||
if [[ -f "$HOME/.ssh/keys/$1" ]]
|
|
||||||
then
|
|
||||||
curl https://$VAULT_DOMAIN/v1/cli/data/$USER/settings/ssh/keys/$1 -X POST --header "X-Vault-Token: ${config["login",$ORG]}" -d "{ \"data\": { \"private\": \"$(cat ~/.ssh/keys/$1 | base64 -w 0)\", \"public\": \"$(cat ~/.ssh/keys/$1.pub | base64 -w 0)\" } }" -s &> /dev/null
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
@ -26,14 +26,14 @@ wx-ssh-sign-create(){
|
|||||||
PRINCIPALS=$2
|
PRINCIPALS=$2
|
||||||
TTL=$3
|
TTL=$3
|
||||||
|
|
||||||
if [[ ! -f "$HOME/.ssh/keys/$NAME" ]]
|
if [[ ! -f "$HOME/.ssh/keys/$NAME-ed25519" ]]
|
||||||
then
|
then
|
||||||
ssh-keygen -t ed25519 -f $HOME/.ssh/keys/$NAME -q -N "" -C "$USER" &> /dev/null
|
ssh-keygen -t ed25519 -f $HOME/.ssh/keys/$NAME-ed25519 -q -N "" &> /dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f "$HOME/.ssh/keys/$NAME" ]]
|
if [[ -f "$HOME/.ssh/keys/$NAME-ed25519" ]]
|
||||||
then
|
then
|
||||||
echo "$NAME/$ROLE"
|
echo "$NAME/$ROLE"
|
||||||
echo $(curl https://$VAULT_DOMAIN/v1/ssh/sign/$ROLE -X POST --header "X-Vault-Token: ${config["login",$ORG]}" -d "{ \"public_key\": \"$(cat $HOME/.ssh/keys/$NAME.pub)\", \"valid_principals\": \"$PRINCIPALS,$USER\", \"ttl\": \"$TTL\" }" -s | jq -r '.data.signed_key') > ~/.ssh/keys/$NAME.sig 2>&1
|
echo $(curl https://$VAULT_DOMAIN/v1/ssh/sign/$ROLE -X POST --header "X-Vault-Token: ${config["login",$ORG]}" -d "{ \"public_key\": \"$(cat $HOME/.ssh/keys/$NAME-ed25519.pub)\", \"valid_principals\": \"$PRINCIPALS,$USER\", \"ttl\": \"$TTL\" }" -s | jq -r '.data.signed_key') > ~/.ssh/keys/$NAME-ed25519.sig 2>&1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
289
wx
289
wx
@ -19,117 +19,6 @@ wxNormal=$(tput sgr0)
|
|||||||
|
|
||||||
declare -Ax config
|
declare -Ax config
|
||||||
|
|
||||||
wx-start(){
|
|
||||||
echo ""
|
|
||||||
echo ""
|
|
||||||
echo ""
|
|
||||||
echo "=============================="
|
|
||||||
echo -n "$wxBold"
|
|
||||||
echo " Warén CLI "
|
|
||||||
echo -n "$wxNormal"
|
|
||||||
echo "=============================="
|
|
||||||
|
|
||||||
mkdir -p $HOME/.config/warengroup &> /dev/null
|
|
||||||
|
|
||||||
if [[ ! -f "$HOME/.config/warengroup/config.json" ]]
|
|
||||||
then
|
|
||||||
echo '{}' | jq > $HOME/.config/warengroup/config.json
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
wx-stop (){
|
|
||||||
echo " "
|
|
||||||
echo " "
|
|
||||||
echo " "
|
|
||||||
if [[ -f "./wx" ]] && [[ -d "./src" ]]
|
|
||||||
then
|
|
||||||
podman run -it --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp docker.io/library/php:8-cli php generator.php &> /dev/null
|
|
||||||
mv wx.tmp wx &> /dev/null
|
|
||||||
chmod +x wx &> /dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir $HOME/bin &> /dev/null
|
|
||||||
curl https://git.waren.io/warengroup/wx/raw/branch/master/wx -o $HOME/bin/wx &> /dev/null
|
|
||||||
chmod +x $HOME/bin/wx &> /dev/null
|
|
||||||
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
wx-auto(){
|
|
||||||
wx-ssh-config-sync
|
|
||||||
wx-ssh-keys-sync
|
|
||||||
wx-ssh-sign
|
|
||||||
}
|
|
||||||
|
|
||||||
wx-help(){
|
|
||||||
|
|
||||||
echo " >> Help << "
|
|
||||||
echo "------------------------------"
|
|
||||||
|
|
||||||
echo -n "
|
|
||||||
Usage: $0 COMMAND [OPTIONS]
|
|
||||||
|
|
||||||
Common Commands:
|
|
||||||
init Init
|
|
||||||
help Help
|
|
||||||
ssh SSH
|
|
||||||
config Config
|
|
||||||
edit Edit
|
|
||||||
save Save
|
|
||||||
sync Sync
|
|
||||||
keys Keys
|
|
||||||
generate Generate
|
|
||||||
delete Delete
|
|
||||||
save Save
|
|
||||||
sync Sync
|
|
||||||
sign Certificates
|
|
||||||
|
|
||||||
Management Commands:
|
|
||||||
auto Auto
|
|
||||||
login Login
|
|
||||||
settings Settings
|
|
||||||
";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
wx-infra(){
|
|
||||||
wx-login
|
|
||||||
wx-ssh-sign &> /dev/null
|
|
||||||
|
|
||||||
echo " >> Infra << "
|
|
||||||
echo "------------------------------"
|
|
||||||
|
|
||||||
INFRA_PATH="/home/cwchristerw/Desktop/Work in Progress/Programming/warengroup/infra"
|
|
||||||
|
|
||||||
case $USER in
|
|
||||||
cwchristerw)
|
|
||||||
if [[ -z $1 ]]
|
|
||||||
then
|
|
||||||
echo "Tag Required"
|
|
||||||
else
|
|
||||||
if [[ $1 == "init" ]]
|
|
||||||
then
|
|
||||||
if [[ -z $2 ]]
|
|
||||||
then
|
|
||||||
echo "Tag Required"
|
|
||||||
else
|
|
||||||
cd "$INFRA_PATH"
|
|
||||||
ansible-playbook --vault-id warengroup@vault/warengroup playbooks/init.yml -t $2 $3 $4 $5 $6 $7 $8 $9
|
|
||||||
cd "$OLDPWD"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
cd "$INFRA_PATH"
|
|
||||||
ansible-playbook --vault-id warengroup@vault/warengroup playbooks.yml -t $1 $2 $3 $4 $5 $6 $7 $8 $9
|
|
||||||
cd "$OLDPWD"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "User Unsupported"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
wx-login(){
|
wx-login(){
|
||||||
ORG=$1
|
ORG=$1
|
||||||
|
|
||||||
@ -312,6 +201,98 @@ wx-login(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wx-start(){
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "=============================="
|
||||||
|
echo -n "$wxBold"
|
||||||
|
echo " Warén CLI "
|
||||||
|
echo -n "$wxNormal"
|
||||||
|
echo "=============================="
|
||||||
|
|
||||||
|
mkdir -p $HOME/.config/warengroup &> /dev/null
|
||||||
|
|
||||||
|
if [[ ! -f "$HOME/.config/warengroup/config.json" ]]
|
||||||
|
then
|
||||||
|
echo '{}' | jq > $HOME/.config/warengroup/config.json
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
wx-stop (){
|
||||||
|
echo " "
|
||||||
|
echo " "
|
||||||
|
echo " "
|
||||||
|
if [[ -f "./wx" ]] && [[ -d "./src" ]]
|
||||||
|
then
|
||||||
|
podman run -it --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp docker.io/library/php:8-cli php generator.php &> /dev/null
|
||||||
|
mv wx.tmp wx &> /dev/null
|
||||||
|
chmod +x wx &> /dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir $HOME/bin &> /dev/null
|
||||||
|
curl https://git.waren.io/warengroup/wx/raw/branch/master/wx -o $HOME/bin/wx &> /dev/null
|
||||||
|
chmod +x $HOME/bin/wx &> /dev/null
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
wx-help(){
|
||||||
|
|
||||||
|
echo " >> Help << "
|
||||||
|
echo "------------------------------"
|
||||||
|
|
||||||
|
echo -n "
|
||||||
|
Usage: $0 COMMAND [OPTIONS]
|
||||||
|
|
||||||
|
Common Commands:
|
||||||
|
init Init
|
||||||
|
ssh SSH
|
||||||
|
config Config
|
||||||
|
sign Certificates
|
||||||
|
|
||||||
|
Management Commands:
|
||||||
|
settings Settings
|
||||||
|
";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
wx-infra(){
|
||||||
|
wx-login
|
||||||
|
wx-ssh-sign &> /dev/null
|
||||||
|
|
||||||
|
echo " >> Infra << "
|
||||||
|
echo "------------------------------"
|
||||||
|
|
||||||
|
case $USER in
|
||||||
|
cwchristerw)
|
||||||
|
if [[ -z $1 ]]
|
||||||
|
then
|
||||||
|
echo "Tag Required"
|
||||||
|
else
|
||||||
|
if [[ $1 == "init" ]]
|
||||||
|
then
|
||||||
|
if [[ -z $2 ]]
|
||||||
|
then
|
||||||
|
echo "Tag Required"
|
||||||
|
else
|
||||||
|
cd "/home/cwchristerw/Desktop/Work in Progress/Programming/warengroup/infra"
|
||||||
|
ansible-playbook --vault-id warengroup@vault/warengroup playbooks/init.yml -t $2 $3 $4 $5 $6 $7 $8 $9
|
||||||
|
cd "$OLDPWD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
cd "/home/cwchristerw/Desktop/Work in Progress/Programming/warengroup/infra"
|
||||||
|
ansible-playbook --vault-id warengroup@vault/warengroup playbooks.yml -t $1 $2 $3 $4 $5 $6 $7 $8 $9
|
||||||
|
cd "$OLDPWD"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "User Unsupported"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
wx-settings(){
|
wx-settings(){
|
||||||
wx-login
|
wx-login
|
||||||
|
|
||||||
@ -326,9 +307,6 @@ wx-ssh(){
|
|||||||
sign)
|
sign)
|
||||||
wx-ssh-sign
|
wx-ssh-sign
|
||||||
;;
|
;;
|
||||||
keys)
|
|
||||||
wx-ssh-keys $2 $3
|
|
||||||
;;
|
|
||||||
config)
|
config)
|
||||||
wx-ssh-config $2
|
wx-ssh-config $2
|
||||||
;;
|
;;
|
||||||
@ -367,6 +345,8 @@ wx-ssh-config(){
|
|||||||
wx-stop
|
wx-stop
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-config-edit(){
|
wx-ssh-config-edit(){
|
||||||
@ -374,80 +354,11 @@ wx-ssh-config-edit(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-config-save(){
|
wx-ssh-config-save(){
|
||||||
curl https://$VAULT_DOMAIN/v1/cli/data/$USER/settings/ssh/config -X POST --header "X-Vault-Token: ${config["login",$ORG]}" -d "{ \"data\": { \"data\": \"$(cat ~/.ssh/config | base64 -w 0)\" } }" -s &> /dev/null
|
curl https://$VAULT_DOMAIN/v1/cli/data/$USER -X POST --header "X-Vault-Token: ${config["login",$ORG]}" -d "{ \"data\": { \"settings/ssh/config\": \"$(cat ~/.ssh/config | base64 -w 0)\" } }" -s &> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-config-sync(){
|
wx-ssh-config-sync(){
|
||||||
VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/cli/data/$USER/settings/ssh/config -X GET --header "X-Vault-Token: ${config["login",$ORG]}")
|
echo $(curl https://$VAULT_DOMAIN/v1/cli/data/$USER -X GET --header "X-Vault-Token: ${config["login",$ORG]}" -s | jq -r '.data.data["settings/ssh/config"]') | base64 -d > ~/.ssh/config 2>&1
|
||||||
if [[ $VAULT_STATUS -eq 200 ]]
|
|
||||||
then
|
|
||||||
echo $(curl https://$VAULT_DOMAIN/v1/cli/data/$USER/settings/ssh/config -X GET --header "X-Vault-Token: ${config["login",$ORG]}" -s | jq -r '.data.data.data') | base64 -d > ~/.ssh/config 2>&1
|
|
||||||
else
|
|
||||||
echo "Status: Config Required"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
wx-ssh-keys(){
|
|
||||||
echo " >> SSH / Keys << "
|
|
||||||
echo "------------------------------"
|
|
||||||
|
|
||||||
case $1 in
|
|
||||||
generate)
|
|
||||||
wx-ssh-keys-sync $2
|
|
||||||
wx-ssh-keys-generate $2
|
|
||||||
wx-ssh-config-save $2
|
|
||||||
;;
|
|
||||||
retrieve)
|
|
||||||
wx-ssh-keys-retrieve $2
|
|
||||||
;;
|
|
||||||
save)
|
|
||||||
wx-ssh-keys-save $2
|
|
||||||
;;
|
|
||||||
sync)
|
|
||||||
wx-ssh-keys-sync $2
|
|
||||||
;;
|
|
||||||
delete)
|
|
||||||
wx-ssh-keys-remove $2
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
wx-ssh-keys-sync
|
|
||||||
wx-stop
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
wx-ssh-keys-generate(){
|
|
||||||
if [[ ! -z $1 ]]
|
|
||||||
then
|
|
||||||
if [[ ! -f "$HOME/.ssh/keys/$1" ]]
|
|
||||||
then
|
|
||||||
ssh-keygen -t ed25519 -f $HOME/.ssh/keys/$1 -q -N "" -C "$USER" &> /dev/null
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
wx-ssh-keys-retrieve(){
|
|
||||||
if [[ ! -z $1 ]]
|
|
||||||
then
|
|
||||||
VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/cli/data/$USER/settings/ssh/keys/$1 -X GET --header "X-Vault-Token: ${config["login",$ORG]}")
|
|
||||||
if [[ $VAULT_STATUS -eq 200 ]]
|
|
||||||
then
|
|
||||||
echo $(curl https://$VAULT_DOMAIN/v1/cli/data/$USER/settings/ssh/keys/$1 -X GET --header "X-Vault-Token: ${config["login",$ORG]}" -s | jq -r '.data.data.private') | base64 -d > ~/.ssh/keys/$1 2>&1
|
|
||||||
echo $(curl https://$VAULT_DOMAIN/v1/cli/data/$USER/settings/ssh/keys/$1 -X GET --header "X-Vault-Token: ${config["login",$ORG]}" -s | jq -r '.data.data.public') | base64 -d > ~/.ssh/keys/$1.pub 2>&1
|
|
||||||
else
|
|
||||||
echo "Status: Key Required"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
wx-ssh-keys-save(){
|
|
||||||
if [[ ! -z $1 ]]
|
|
||||||
then
|
|
||||||
if [[ -f "$HOME/.ssh/keys/$1" ]]
|
|
||||||
then
|
|
||||||
curl https://$VAULT_DOMAIN/v1/cli/data/$USER/settings/ssh/keys/$1 -X POST --header "X-Vault-Token: ${config["login",$ORG]}" -d "{ \"data\": { \"private\": \"$(cat ~/.ssh/keys/$1 | base64 -w 0)\", \"public\": \"$(cat ~/.ssh/keys/$1.pub | base64 -w 0)\" } }" -s &> /dev/null
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wx-ssh-sign(){
|
wx-ssh-sign(){
|
||||||
@ -478,15 +389,15 @@ wx-ssh-sign-create(){
|
|||||||
PRINCIPALS=$2
|
PRINCIPALS=$2
|
||||||
TTL=$3
|
TTL=$3
|
||||||
|
|
||||||
if [[ ! -f "$HOME/.ssh/keys/$NAME" ]]
|
if [[ ! -f "$HOME/.ssh/keys/$NAME-ed25519" ]]
|
||||||
then
|
then
|
||||||
ssh-keygen -t ed25519 -f $HOME/.ssh/keys/$NAME -q -N "" -C "$USER" &> /dev/null
|
ssh-keygen -t ed25519 -f $HOME/.ssh/keys/$NAME-ed25519 -q -N "" &> /dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f "$HOME/.ssh/keys/$NAME" ]]
|
if [[ -f "$HOME/.ssh/keys/$NAME-ed25519" ]]
|
||||||
then
|
then
|
||||||
echo "$NAME/$ROLE"
|
echo "$NAME/$ROLE"
|
||||||
echo $(curl https://$VAULT_DOMAIN/v1/ssh/sign/$ROLE -X POST --header "X-Vault-Token: ${config["login",$ORG]}" -d "{ \"public_key\": \"$(cat $HOME/.ssh/keys/$NAME.pub)\", \"valid_principals\": \"$PRINCIPALS,$USER\", \"ttl\": \"$TTL\" }" -s | jq -r '.data.signed_key') > ~/.ssh/keys/$NAME.sig 2>&1
|
echo $(curl https://$VAULT_DOMAIN/v1/ssh/sign/$ROLE -X POST --header "X-Vault-Token: ${config["login",$ORG]}" -d "{ \"public_key\": \"$(cat $HOME/.ssh/keys/$NAME-ed25519.pub)\", \"valid_principals\": \"$PRINCIPALS,$USER\", \"ttl\": \"$TTL\" }" -s | jq -r '.data.signed_key') > ~/.ssh/keys/$NAME-ed25519.sig 2>&1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user