1

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?

  • 2
    Why don't you set up key based authentication then? – heemayl Feb 5 '15 at 17:34
  • Security reasons. More people use my computer. Besides I'm fairly sure that this is against company policy. A shortcut would have a good balance between security and practicability. – TomCho Feb 5 '15 at 17:41
  • 2
    So, you are saying that you can't set up key-based authentication but you can save a password as plaintext in a file and copy-paste it....goodness me!!!!......thats a very bad bad option. – heemayl Feb 5 '15 at 17:43
  • A key based authentication with a passphrase will solve all. You remember the passphrase; at the first use of ssh the key agent will ask your passphrase and from now on you don't have to type anything (password nor passphrase) for the whole session. Infinitely more secure of your approach, and even more practical. I am using it since... well... 1995? See for example digitalocean.com/community/tutorials/… – Rmano Feb 5 '15 at 19:16
3

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.