add ssh rc script to fix SSH_AUTH_SOCK on remote hosts

whole-command-tab-completion
bretello 2020-02-14 16:37:44 +01:00
parent 6680bb4828
commit c233b696a6
3 changed files with 23 additions and 4 deletions

View File

@ -79,4 +79,7 @@ will result in green text. Use `$CLEAR` to clear previous escape sequences add B
name to use **bold** and U to underline (examples: $BRed, $UBlack for bold red and underlined black)
3. Type `esc` twice to add `sudo` before the current command
4. Autoupdate script running every two weeks, autoupdate function: dotfiles_selfupdate (or `git pull` from `$DOTFILES` folder)
5.
5. Automatic fix of the `SSH_AUTH_SOCK` enviroment variable: `~/.ssh/rc` is installed run on every ssh login,
and updates a symlink pointing (`~/.ssh/ssh_auth_sock`). `SSH_AUTH_SOCK` points to this (set in `brethil_dotfile.sh`).
The idea is that if the user is logging in using ssh -A, and using tmux, it will be possible to use
the remote socket over different sessions by always using the symlink.

View File

@ -24,7 +24,9 @@ export EDITOR="vim"
export HISTSIZE=100000
export LANG=en_US.UTF-8
if [[ $SSH_CLIENT ]]; then
export SSH_AUTH_SOCK=$HOME/.ssh/ssh_auth_sock
fi
plugins=($shared_plugins $os_extra)

View File

@ -87,9 +87,20 @@ function create_ssh_config {
fi
exec 3>&1 # save stdout file descriptor
# add the ssh rc that symlinks the used SSH_AUTH_SOCK. This will be executed on every ssh login.
# The idea is that if the user is logging in using ssh -A, the symlink will point to the correct
# location of the ssh auth socket and the remote ssh agent will be used.
# SSH_AUTH_SOCK is declared in brethil_dotfile.sh
exec 1>>~/.ssh/rc
echo '#!/bin/bash'
echo 'if test "$SSH_AUTH_SOCK" ; then'
echo ' ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock'
echo 'fi '
chmod 755 ~/.ssh/rc
exec 1>>$ssh_config # redirect everything below to the $ssh_config file
if [[ "$modifyssh" != "n" ]]
then
if [[ "$modifyssh" != "n" ]]; then
echo "# brethil's dotfiles setup start"
echo 'TCPKeepAlive=yes'
echo 'ServerAliveCountMax=6'
@ -205,6 +216,9 @@ function brethil_dotfiles_setup {
sed -i 's/set -g terminal-overrides/#set -g terminal-overrides/' /usr/share/byobu/profiles/tmux
fi
# remove ls from the grc.zsh config:
sed 's|ls \\|#ls \\|' /etc/grc.zsh
# Set m and M to enable/disable mouse mode in tmux/byobu
echo 'bind-key m source $BYOBU_PREFIX/share/byobu/keybindings/mouse.tmux.enable \; display-message "Mouse: ON"' >> ~/.tmux.conf
echo 'bind-key M source $BYOBU_PREFIX/share/byobu/keybindings/mouse.tmux.disable \; display-message "Mouse: Off"' >> ~/.tmux.conf