Code Update
This commit is contained in:
parent
706a917dbf
commit
0ef3f8d8d6
@ -7,7 +7,7 @@ wx-infra(){
|
||||
|
||||
INFRA_PATH="/home/cwchristerw/Desktop/Work in Progress/Programming/warengroup/infra"
|
||||
|
||||
case $USER in
|
||||
case $USERNAME in
|
||||
cwchristerw)
|
||||
if [[ -z $1 ]]
|
||||
then
|
||||
|
@ -78,10 +78,10 @@ wx-login(){
|
||||
echo "Status: Username Required"
|
||||
wx-stop
|
||||
else
|
||||
USER=$LOGNAME
|
||||
USERNAME=$LOGNAME
|
||||
fi
|
||||
else
|
||||
USER=$SUDO_USER
|
||||
USERNAME=$SUDO_USER
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -108,13 +108,12 @@ wx-login(){
|
||||
|
||||
echo $wxBold$ORG$wxNormal
|
||||
|
||||
if [[ -z $USER || $USER == "root" || $USER == "local" ]]
|
||||
if [[ -z $USERNAME || $USERNAME == "root" || $USERNAME == "local" ]]
|
||||
then
|
||||
echo -n "Username: "
|
||||
read USERNAME
|
||||
else
|
||||
echo "Username: $USER"
|
||||
USERNAME=$USER
|
||||
echo "Username: $USERNAME"
|
||||
fi
|
||||
|
||||
echo -n "Password: "
|
||||
|
@ -26,13 +26,13 @@ wx-ssh-config-edit(){
|
||||
}
|
||||
|
||||
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/$USERNAME/settings/ssh/config -X POST --header "X-Vault-Token: ${config["login",$ORG]}" -d "{ \"data\": { \"data\": \"$(cat ~/.ssh/config | base64 -w 0)\" } }" -s &> /dev/null
|
||||
}
|
||||
|
||||
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]}")
|
||||
VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/config -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/config -X GET --header "X-Vault-Token: ${config["login",$ORG]}" -s | jq -r '.data.data.data') | base64 -d > ~/.ssh/config 2>&1
|
||||
echo $(curl https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/config -X GET --header "X-Vault-Token: ${config["login",$ORG]}" -s | jq -r '.data.data.data') | base64 -d > ~/.ssh/config 2>&1
|
||||
fi
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ wx-ssh-keys-generate(){
|
||||
then
|
||||
if [[ ! -f "$HOME/.ssh/keys/$1" ]]
|
||||
then
|
||||
ssh-keygen -t ed25519 -f $HOME/.ssh/keys/$1 -q -N "" -C "$USER" &> /dev/null
|
||||
ssh-keygen -t ed25519 -f $HOME/.ssh/keys/$1 -q -N "" -C "$USERNAME" &> /dev/null
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -40,11 +40,11 @@ wx-ssh-keys-generate(){
|
||||
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]}")
|
||||
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: ${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
|
||||
echo $(curl https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/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/$USERNAME/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
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -54,7 +54,7 @@ wx-ssh-keys-save(){
|
||||
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
|
||||
curl https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/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
|
||||
}
|
||||
|
@ -24,12 +24,12 @@ wx-ssh-sign-create(){
|
||||
|
||||
if [[ ! -f "$HOME/.ssh/keys/$NAME" ]]
|
||||
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 -q -N "" -C "$USERNAME" &> /dev/null
|
||||
fi
|
||||
|
||||
if [[ -f "$HOME/.ssh/keys/$NAME" ]]
|
||||
then
|
||||
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.pub)\", \"valid_principals\": \"$PRINCIPALS,$USERNAME\", \"ttl\": \"$TTL\" }" -s | jq -r '.data.signed_key') > ~/.ssh/keys/$NAME.sig 2>&1
|
||||
fi
|
||||
}
|
||||
|
@ -9,9 +9,12 @@ wx-stop (){
|
||||
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
|
||||
if [[ $USER != "root" && $USER != "local" ]]
|
||||
then
|
||||
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
|
||||
fi
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
40
wx
40
wx
@ -48,9 +48,12 @@ wx-stop (){
|
||||
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
|
||||
if [[ $USER != "root" && $USER != "local" ]]
|
||||
then
|
||||
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
|
||||
fi
|
||||
|
||||
exit 1
|
||||
}
|
||||
@ -106,7 +109,7 @@ wx-infra(){
|
||||
|
||||
INFRA_PATH="/home/cwchristerw/Desktop/Work in Progress/Programming/warengroup/infra"
|
||||
|
||||
case $USER in
|
||||
case $USERNAME in
|
||||
cwchristerw)
|
||||
if [[ -z $1 ]]
|
||||
then
|
||||
@ -215,10 +218,10 @@ wx-login(){
|
||||
echo "Status: Username Required"
|
||||
wx-stop
|
||||
else
|
||||
USER=$LOGNAME
|
||||
USERNAME=$LOGNAME
|
||||
fi
|
||||
else
|
||||
USER=$SUDO_USER
|
||||
USERNAME=$SUDO_USER
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -245,13 +248,12 @@ wx-login(){
|
||||
|
||||
echo $wxBold$ORG$wxNormal
|
||||
|
||||
if [[ -z $USER || $USER == "root" || $USER == "local" ]]
|
||||
if [[ -z $USERNAME || $USERNAME == "root" || $USERNAME == "local" ]]
|
||||
then
|
||||
echo -n "Username: "
|
||||
read USERNAME
|
||||
else
|
||||
echo "Username: $USER"
|
||||
USERNAME=$USER
|
||||
echo "Username: $USERNAME"
|
||||
fi
|
||||
|
||||
echo -n "Password: "
|
||||
@ -382,14 +384,14 @@ wx-ssh-config-edit(){
|
||||
}
|
||||
|
||||
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/$USERNAME/settings/ssh/config -X POST --header "X-Vault-Token: ${config["login",$ORG]}" -d "{ \"data\": { \"data\": \"$(cat ~/.ssh/config | base64 -w 0)\" } }" -s &> /dev/null
|
||||
}
|
||||
|
||||
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]}")
|
||||
VAULT_STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/config -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/config -X GET --header "X-Vault-Token: ${config["login",$ORG]}" -s | jq -r '.data.data.data') | base64 -d > ~/.ssh/config 2>&1
|
||||
echo $(curl https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/settings/ssh/config -X GET --header "X-Vault-Token: ${config["login",$ORG]}" -s | jq -r '.data.data.data') | base64 -d > ~/.ssh/config 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
@ -427,7 +429,7 @@ wx-ssh-keys-generate(){
|
||||
then
|
||||
if [[ ! -f "$HOME/.ssh/keys/$1" ]]
|
||||
then
|
||||
ssh-keygen -t ed25519 -f $HOME/.ssh/keys/$1 -q -N "" -C "$USER" &> /dev/null
|
||||
ssh-keygen -t ed25519 -f $HOME/.ssh/keys/$1 -q -N "" -C "$USERNAME" &> /dev/null
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -435,11 +437,11 @@ wx-ssh-keys-generate(){
|
||||
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]}")
|
||||
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: ${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
|
||||
echo $(curl https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/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/$USERNAME/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
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -449,7 +451,7 @@ wx-ssh-keys-save(){
|
||||
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
|
||||
curl https://$VAULT_DOMAIN/v1/cli/data/$USERNAME/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
|
||||
}
|
||||
@ -484,13 +486,13 @@ wx-ssh-sign-create(){
|
||||
|
||||
if [[ ! -f "$HOME/.ssh/keys/$NAME" ]]
|
||||
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 -q -N "" -C "$USERNAME" &> /dev/null
|
||||
fi
|
||||
|
||||
if [[ -f "$HOME/.ssh/keys/$NAME" ]]
|
||||
then
|
||||
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.pub)\", \"valid_principals\": \"$PRINCIPALS,$USERNAME\", \"ttl\": \"$TTL\" }" -s | jq -r '.data.signed_key') > ~/.ssh/keys/$NAME.sig 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user