update yubikey switch
This commit is contained in:
parent
48d49081be
commit
70a16bbf8b
7 changed files with 81 additions and 5 deletions
53
.config/scripts/ssh.sh
Executable file
53
.config/scripts/ssh.sh
Executable file
|
|
@ -0,0 +1,53 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
yubikeys=$(ykman list)
|
||||||
|
|
||||||
|
# Check if any YubiKeys were found
|
||||||
|
if [[ -z "$yubikeys" ]]; then
|
||||||
|
echo "No YubiKeys found."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
selected=$(echo "$yubikeys" | wofi --dmenu -i)
|
||||||
|
|
||||||
|
# Check if the user made a selection
|
||||||
|
if [[ -z "$selected" ]]; then
|
||||||
|
echo "No selection made."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
YUBIKEY_SERIAL=$(echo "$selected" | awk '{print $NF}')
|
||||||
|
|
||||||
|
if [ -L "$HOME/.ssh/id_rsa" ]; then
|
||||||
|
rm "$HOME/.ssh/id_rsa"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create the symbolic link
|
||||||
|
ln -s "$HOME/.config/yubikey/id_$YUBIKEY_SERIAL" $HOME/.ssh/id_rsa
|
||||||
|
chmod 600 "$HOME/.ssh/id_rsa"
|
||||||
|
|
||||||
|
if [ -n "$SSH_AGENT_PID" ]; then
|
||||||
|
kill "$SSH_AGENT_PID"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start a new ssh-agent
|
||||||
|
eval $(ssh-agent -s)
|
||||||
|
|
||||||
|
# Update tmux sessions
|
||||||
|
tmux ls 2>/dev/null | cut -d ':' -f1 | while read -r session_name; do
|
||||||
|
tmux setenv -t "$session_name" SSH_AUTH_SOCK "$SSH_AUTH_SOCK"
|
||||||
|
tmux setenv -t "$session_name" SSH_AGENT_PID "$SSH_AGENT_PID"
|
||||||
|
tmux refresh-client -t "$session_name"
|
||||||
|
echo "Updated tmux session: $session_name"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Check if the symbolic link was created successfully
|
||||||
|
if [ -L "$HOME/.ssh/id_rsa" ]; then
|
||||||
|
echo "Symbolic link created successfully at $target"
|
||||||
|
else
|
||||||
|
echo "Failed to create symbolic link at $target"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
notify-send "SSH Key has been updated for $(echo $selected | awk '{split($0,a,"("); print a[1]}')"
|
||||||
|
exit 0
|
||||||
|
|
@ -8,8 +8,7 @@ alias pwsh='pwsh -NoLogo'
|
||||||
alias pbpaste='xclip -selection clipboard -o'
|
alias pbpaste='xclip -selection clipboard -o'
|
||||||
alias ls='eza'
|
alias ls='eza'
|
||||||
alias ll='eza -l'
|
alias ll='eza -l'
|
||||||
alias lg='~/.config/scripts/yubikey.sh lazygit'
|
alias lg='lazygit'
|
||||||
alias lazygit='~/.config/scripts/yubikey.sh lazygit'
|
|
||||||
alias tree='eza -T'
|
alias tree='eza -T'
|
||||||
alias cat='bat -P'
|
alias cat='bat -P'
|
||||||
alias network='nmtui'
|
alias network='nmtui'
|
||||||
|
|
@ -20,5 +19,4 @@ alias connectvpn='sudo openvpn ~/Documents/openvpn/openvpn.ovpn'
|
||||||
alias gc='git commit -a'
|
alias gc='git commit -a'
|
||||||
alias gd='git diff'
|
alias gd='git diff'
|
||||||
alias gp='git push'
|
alias gp='git push'
|
||||||
alias bw='NODE_OPTIONS="--no-deprecation" bw'
|
alias bw='NODE_OPTIONS="" bw'
|
||||||
alias git='~/.config/scripts/yubikey.sh git'
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ set $bitwarden flatpak run com.bitwarden.desktop
|
||||||
set $menu wofi
|
set $menu wofi
|
||||||
set $scripts "$HOME/.config/scripts"
|
set $scripts "$HOME/.config/scripts"
|
||||||
set $otpScript "$HOME/.config/scripts/otp.sh"
|
set $otpScript "$HOME/.config/scripts/otp.sh"
|
||||||
|
set $sshScript "$scripts/ssh.sh"
|
||||||
set $newScript "$HOME/.config/scripts/sessions.sh"
|
set $newScript "$HOME/.config/scripts/sessions.sh"
|
||||||
|
|
||||||
set $next_or_new swaymsg -r -t get_workspaces | jq -r --arg OUTPUT $(swaymsg -t get_outputs -r | jq -r '.[] | select(.focused == true) | .name') '(. | (max_by(.num) | .num)) as $max | [.[] | select(.output == $OUTPUT)] | (max_by(.num) | .num) as $maxOutput | (.[] | select(.focused == true) | .num) as $current | if $maxOutput > $current then "next_on_output" else $max + 1 end'
|
set $next_or_new swaymsg -r -t get_workspaces | jq -r --arg OUTPUT $(swaymsg -t get_outputs -r | jq -r '.[] | select(.focused == true) | .name') '(. | (max_by(.num) | .num)) as $max | [.[] | select(.output == $OUTPUT)] | (max_by(.num) | .num) as $maxOutput | (.[] | select(.focused == true) | .num) as $current | if $maxOutput > $current then "next_on_output" else $max + 1 end'
|
||||||
|
|
@ -100,6 +101,8 @@ bindsym $mod+control+n exec swaync-client -t -sw
|
||||||
# Start otp script
|
# Start otp script
|
||||||
bindsym $mod+Shift+o exec 'zsh -c ". $otpScript"'
|
bindsym $mod+Shift+o exec 'zsh -c ". $otpScript"'
|
||||||
|
|
||||||
|
# Start ssh script
|
||||||
|
bindsym $mod+Shift+y exec 'zsh -c ". $sshScript"'
|
||||||
|
|
||||||
# Audio Switch
|
# Audio Switch
|
||||||
bindsym $mod+Shift+s exec 'bash -c ". $scripts/audioswitch.sh"'
|
bindsym $mod+Shift+s exec 'bash -c ". $scripts/audioswitch.sh"'
|
||||||
|
|
|
||||||
10
.config/yubikey/id_28854922
Normal file
10
.config/yubikey/id_28854922
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
-----BEGIN OPENSSH PRIVATE KEY-----
|
||||||
|
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAASgAAABpzay1zc2
|
||||||
|
gtZWQyNTUxOUBvcGVuc3NoLmNvbQAAACBopXJ3WrTK14NOlcbTSriKN7HKMsl22F/Ge3Do
|
||||||
|
3gNdNgAAAARzc2g6AAABAF6FOOhehTjoAAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY2
|
||||||
|
9tAAAAIGilcndatMrXg06VxtNKuIo3scoyyXbYX8Z7cOjeA102AAAABHNzaDoBAAAAgNmr
|
||||||
|
3qLxvZzujrI7RpTw0+JxdhTdJkcFp6XXl5FIUvMle/Ql+PxougbOwESf9FzZtHGBAK+Eie
|
||||||
|
zEk8aIK74fqxEbG9lo+Yfte5WEhEibW+U7z25VyZoOhZDGGDR30Ato7zb1Q4M7i/NAhWl0
|
||||||
|
kLm2MPipU3uEaQAkh4G7m+fiAc3nAAAAAAAAAB9kZXNrdG9wLWFyY2gtMDktMDgtMjAyNS
|
||||||
|
15dWJpa2V5AQI=
|
||||||
|
-----END OPENSSH PRIVATE KEY-----
|
||||||
1
.config/yubikey/id_28854922.pub
Normal file
1
.config/yubikey/id_28854922.pub
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIGilcndatMrXg06VxtNKuIo3scoyyXbYX8Z7cOjeA102AAAABHNzaDo= desktop-arch-09-08-2025-yubikey
|
||||||
10
.config/yubikey/id_33923085
Normal file
10
.config/yubikey/id_33923085
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
-----BEGIN OPENSSH PRIVATE KEY-----
|
||||||
|
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAASgAAABpzay1zc2
|
||||||
|
gtZWQyNTUxOUBvcGVuc3NoLmNvbQAAACDbGzUmeVq/udAIc/iHmcbehe4GesJtSfLil0C2
|
||||||
|
3WyhWgAAAARzc2g6AAABCM6TagvOk2oLAAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY2
|
||||||
|
9tAAAAINsbNSZ5Wr+50Ahz+IeZxt6F7gZ6wm1J8uKXQLbdbKFaAAAABHNzaDoBAAAAgOQ9
|
||||||
|
IpvCe40b/gNFaY2gQSZ0pFRUCnXaXO6EeKH8wSSDegIZSjbn56mty5IP9Lu7tb7tYW0emR
|
||||||
|
qG274uTcHpnxANEIVVInJ8gxvLJXB7drDz2Nfv0ORaTqYf8Cl8JXq681byZe3/MvmcJbSF
|
||||||
|
BJqD7aNEntfYJk+YpaXbdxQ5WgoUAAAAAAAAACNkZXNrdG9wLWFyY2gtMDktMDgtMjAyNS
|
||||||
|
15dWJpa2V5TmFubwECAwQFBg==
|
||||||
|
-----END OPENSSH PRIVATE KEY-----
|
||||||
1
.config/yubikey/id_33923085.pub
Normal file
1
.config/yubikey/id_33923085.pub
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAINsbNSZ5Wr+50Ahz+IeZxt6F7gZ6wm1J8uKXQLbdbKFaAAAABHNzaDo= desktop-arch-09-08-2025-yubikeyNano
|
||||||
Loading…
Add table
Add a link
Reference in a new issue