Ubuntu – Shortcut to automatically paste a specific string in terminal

shortcut-keysssh

I have to connect to several ssh connections daily and they all have the same password, which is really complicated (enough that it is virtually impossible to memorize it). So what I have to do several times a day is copy it from a .txt file and paste it in the terminal with ctrl+shift+V when it prompts me for it.

I have always wondered how to do this automatically and, since I do want the terminal to prompt me for the password for safety reasons, the only way I can think of doing it is by somehow creating a shortcut that pastes this specific password into the terminal (or at least a shortcut that puts this password in the clipboard for me to paste it). I know how you can edit shortcuts, I just can't figure out what would be the command that would do this.

I have gone through numerous forum posts and some doc pages but nothing has given me an idea of how to actually do this. Can anyone please give me a hand on this one?

Best Answer

I could show you a way, but it is not exactly what you might need.

  1. First install xsel
  2. Let's say the file which contains the password is named password.txt and is located in you home folder. Do the following, before entering the command that requires the password xsel --clipboard < ~/password.txt.
  3. Now the password is in your clipboard and you can paste it using Ctrl + Shift + V.

You might find it boring to enter this command; you can then create an alias for it by editing .bashrc