Fix the ssh command
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
[user]
|
||||
email = stofflees@gmail.com
|
||||
name = Chris
|
||||
[pull]
|
||||
rebase = true
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
export MASTERPW=$(dialog --no-cancel --passwordbox "Enter Enpass master password." 10 60 3>&1 1>&2 2>&3 3>&1)
|
||||
export MASTERPW=$(dialog --no-cancel --passwordbox "Enter Enpass master password." 10 60 3>&1 1>&2 2>&3 3>&1 | sed 's/\s//g')
|
||||
|
||||
echo MASTERPW | xclip -loops 2 -selection clipboard -i
|
||||
echo "$MASTERPW" | xclip -loops 5 -selection clipboard -i
|
||||
|
||||
enpass
|
||||
enpass &
|
||||
|
||||
read -n 1 -r -s -p $'Press enter when you have synced enpass...\n'
|
||||
|
||||
CHECKPW=$(enpasscli -vault="$HOME/Documents/Enpass/Vaults/primary" -sort list)
|
||||
CHECKPW=$(enpasscli -vault="$HOME/Documents/Enpass/Vaults/primary" -sort list 2>&1)
|
||||
|
||||
while [[ "$CHECKPW" == *level=fatal* ]]; do
|
||||
export MASTERPW=$(dialog --no-cancel --passwordbox "That password didn't work, please try again" 10 60 3>&1 1>&2 2>&3 3>&1)
|
||||
CHECKPW=$(enpasscli -vault="$HOME/Documents/Enpass/Vaults/primary" -sort list)
|
||||
done
|
||||
|
||||
echo "Password set successfuly"
|
||||
|
||||
./ssh
|
||||
|
||||
@@ -9,13 +9,15 @@ SSHPATH="$HOME/.ssh/id_ed25519" # The path to the SSH key file
|
||||
TITLE="$USER@$(cat /etc/hostname)" # The title for the SSH key
|
||||
|
||||
# Generate the SSH key if it does not exist
|
||||
if [ ! -f $SSHPATH ] && ssh-keygen -t ed25519 -f "$SSHPATH" -N "" -q
|
||||
[ ! -f $SSHPATH ] && ssh-keygen -t ed25519 -f "$SSHPATH" -N "" -q
|
||||
|
||||
KEY=$(cat "$SSHPATH.pub")
|
||||
|
||||
# A method to generate the parameters for creating an SSH key on gitea
|
||||
generate_post_data() {
|
||||
cat <<EOF
|
||||
{
|
||||
"key": "$(cat "$SSHPATH.pub")",
|
||||
"key": "$KEY",
|
||||
"read_only": false,
|
||||
"title": "$TITLE"
|
||||
}
|
||||
@@ -23,14 +25,14 @@ EOF
|
||||
}
|
||||
|
||||
CREDENTIALS="$LABSUN:$LABSPW" # The credentials to pass to the API
|
||||
KEYS_URL="https://$CREDENTIALS@labs.scarif.space/api/v1/users/keys"
|
||||
KEYS_URL="https://$CREDENTIALS@labs.scarif.space/api/v1/user/keys"
|
||||
|
||||
# Get all the existing keys
|
||||
KEYS=$(curl -X GET -s --url "$KEYS_URL")
|
||||
|
||||
KEY_EXISTS=$(echo $KEYS | jq --arg KEY "$(cat "$SSHPATH.pub")" 'contains({ key: $KEY })')
|
||||
KEY_EXISTS=$(echo $KEYS | jq --arg TITLE "$TITLE" 'map(.title)|contains([$TITLE])')
|
||||
|
||||
if [[ $KEY_EXISTS != true ]]; do
|
||||
if [[ $KEY_EXISTS != true ]]; then
|
||||
# Extract the ids of the keys with the same title as this machine
|
||||
IDS=$(echo $KEYS | jq --arg TITLE "$TITLE" 'map(select(.title == $TITLE))[].id')
|
||||
|
||||
@@ -65,6 +67,6 @@ for dir in $(ls "$HOME/.local/src"); do
|
||||
fi
|
||||
done
|
||||
|
||||
DOTFILES_SSH_URL=$(git --git-dir "$HOME/.config/dotfiles/.git" --work-tree="$HOME" get-url origin | sed "$HTTP_REPLACE")
|
||||
git --git-dir "$HOME/.config/dotfiles/.git" --work-tree="$HOME" set-url origin "$DOTFILES_SSH_URL"
|
||||
DOTFILES_SSH_URL=$(git --git-dir "$HOME/.config/dotfiles/.git" --work-tree="$HOME" remote get-url origin | sed "$HTTP_REPLACE")
|
||||
git --git-dir "$HOME/.config/dotfiles/.git" --work-tree="$HOME" remote set-url origin "$DOTFILES_SSH_URL"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user