# 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 ~/.config/fish/config.fish # # Notes: to change the location of the directory ~/.passwords, configure PASSWORD_DIR. # set PASSWORD_DIR ~/.passwords function copypass if [ -z "$argv[1]" ] echo Usage: copypass host-name return end if [ ! -f "$PASSWORD_DIR/$argv[1]" ] echo "$PASSWORD_DIR/$argv[1]" does not exist. echo You should put your password for "$argv[1]" in the text file "$PASSWORD_DIR/$argv[1]" return end cat "$PASSWORD_DIR/$argv[1]" | xclip -selection clipboard end function pash copypass $argv ssh $argv end