Skip to content
Snippets Groups Projects
Commit 9c5bbeb0 authored by nimrod's avatar nimrod
Browse files

Fix issue with ControlMaster sockets pruning.

The prune_ssh_sockets shell function would always delete the
ControlMaster sockets (the open file handlers would have a random suffix
and the check would always show that the socket wasn't open by any
process). Instead add a prefix to the ControlMaster sockets and ignore
them when pruning. Those sockets are always deleted when the process
exists. Also, mark the vim filetype for the ssh config fragments as
sshconfig.
parent 6c992b1a
Branches
No related tags found
No related merge requests found
......@@ -293,11 +293,14 @@ flatpak_kill () {
fi
}
__prune_docker_remote () {
for i in ~/.ssh/docker_*
do
[ ! -e "$i" ] || lsof -t "$i" >/dev/null || rm "$i"
done
# shellcheck disable=SC2120
prune_ssh_sockets () {
( [ "${1:-}" != '-f' ] && [ "${1:-}" != '--force' ] ) || killall -v ssh || true
find ~/.ssh/ \
-maxdepth 1 \
-type s \
\! -name 'cm_*.sock' \
-execdir sh -c 'lsof -t "$1" >/dev/null || rm "$1"' _ {} \;
}
__prompt () {
......@@ -383,4 +386,5 @@ then
! command -v direnv > /dev/null || eval "$(direnv hook bash)"
fi
__prune_docker_remote
# shellcheck disable=SC2119
prune_ssh_sockets
# vim:ft=sshconfig
#Endless
Host appupdates.endlessm.com irc.endlessm.com status.endlessm.com
......
# vim:ft=sshconfig
# github.com
Host github.com
......
# vim:ft=sshconfig
# shore.co.il infrastructure
Host cgit.shore.co.il host01.shore.co.il wdr4300.shore.co.il xbmc.shore.co.il
......
# vim:ft=sshconfig
# localhost
Host localhost
......
# vim:ft=sshconfig
# Disable SSH host key checking for EC2 instances.
Host *.compute-1.amazonaws.com
......
......@@ -7,7 +7,7 @@ usage () {
host="$1" || { usage >&2; exit 1; }
forward="$2" || { usage >&2; exit 1; }
alias ssh='ssh -fnNTS ~/.ssh/%C.sock'
alias ssh='ssh -fnNTS ~/.ssh/cm_%C.sock'
# shellcheck disable=SC2029
ssh -o ControlMaster=auto \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment