# Usage: # # pash hostname # myself@hostname:~$ sudo ls # [sudo] password for myself: CTRL+SHIFT+V # # In other words, it copies your password in your clipboard and does 'ssh hostname'. # Then, you can quickly paste your password when needed. # # The command 'copypass hostname' just copies your password in the clipboard. # # Installation # # 1. install xclip: sudo apt install xclip # # 2. Create a directory where, for each of your remote server, you create a file with your password. # Be sure to have your harddisk encrypted, or use an encrypted directory. # Also, do a chmod 700 of the directory. # Example: say your remote servers are nas-router, core.pippo.org, dev.topolino.org, ... # mkdir ~/.passwords # chmod 700 ~/.passwords # echo "a secret password" > ~/.passwords/nas-router # echo "my secret password" > ~/.passwords/core.pippo.org # echo "another secret password" > ~/.passwords/dev.topolino.org # # 3. Put this code in your ~/.bashrc. Configure the PASSWORD_DIR variable here. # # Author: Alpt (freaknet.org) # gopher://medialab.freaknet.org/0/alpt/utils/copypass PASSWORD_DIR="$HOME/.passwords" copypass() { if [ -z "$1" ] then echo Usage: copypass host-name return fi if [ ! -f "$PASSWORD_DIR/$1" ] then echo "$PASSWORD_DIR/$1" does not exist. echo You should put your password for "$1" in the text file "$PASSWORD_DIR/$1" return fi cat "$PASSWORD_DIR/$1" | xclip -selection clipboard } pash() { copypass "$@" ssh "$@" } complete -W "$(ls -1 "$PASSWORD_DIR")" copypass complete -W "$(ls -1 "$PASSWORD_DIR")" pash # vim: filetype=sh