So I googled and found out that you can create aliases in .bashrc to ensure you have a quick access to your ssh servers like so :

alias connectme='ssh root@ -p 999'

that's quite nice I only have to type connectme and the password. I googled some more and it turns out you can do this

alias connectme='sshpass -p "thepasswordincleartext" ssh root@ -p 999'

(yes the second -p is correctly passed as "port" not "password" to the second command; ssh ) I googled some more ans started creating a .desktop launcher.

that's when I hit a road bump :

  • either the passwordless version of that alias works but I have to type password everytime.
  • or I add sshpass and the terminal window closes upon completion of the connection.

(I tried forcing terminal to stay open upon command completion in it's options, that's when I realised .desktop runners actually type out "exit" and force the disconnect)

here's what I'm working with :

#!/usr/bin/env xdg-open
[Desktop Entry]
Exec=bash -c 'exec bash -i <<<"connectme"'

this elaborate stupidity :

bash -c 'exec bash -i <<<"command"'

is done because for some reason Exec doesn't encompass the bash and your userspace realm. I haven't got a clue why not.

How do I set up a working launcher for ssh with bundled password (and why not a first command piped to the remote server upon connection)?

I'm willing to edit environement if that's what it takes.

  • Instead of passing the password, I would recommend to use passwordless login. Not sure about the launcher, but I once answered a similar question that will allow you to do ssh yourserver that might be useful askubuntu.com/questions/1027428/… – Katu Mar 1 '19 at 8:18
  • that's a pretty good solution, thanks! idealy I wouldn't have modified those servers but noone should notice. although the launcher still quits and it doesn't find "connectme" whereas in a regular terminal it does. – tatsu Mar 1 '19 at 10:04
  • I think that any reasonable server admin would rather you add your public ssh key to it than have the password written in plain text in an uncontrolled machine. Just remember not to share your private key with anyone. – Katu Mar 1 '19 at 11:07
  • ok. that still doesn't solve the launcher-terminal-closing issue, though. – tatsu Mar 1 '19 at 12:06

Rather than put paswords in your alias, use ssh-copy-id to copy your PUBLIC ssh key to the target, and use ~/.ssh/config to specify details. For an example, here's my ~/.ssh/config:

$ cat .ssh/config
# alias aardvark='ssh -l w3 aardvark '
# alias cookie='ssh -l walt cookie '
# alias fw='ssh -l root -p 8022 spark2y '
# alias squid='ssh -l walt squid '
# alias wombat='ssh -l walt wombat '
Host aa
     Hostname aardvark
     User w3
     ForwardX11 yes
     Protocol 2

Host ck
     Hostname cookie
     User walt
     ForwardX11 yes
     Protocol 2

Host fw
     Hostname spark2y
     User root
     Port 8022
     ForwardX11 yes
     Protocol 2

Host sq
     Hostname squid
     User walt
     ForwardX11 yes
     Protocol 2

Host wm
     Hostname wombat
     User walt
     ForwardX11 yes
     Protocol 2

Read man ssh-copy-id;man ssh;man ssh_config.

  • well my end goal was to have launchers. I did the above and that's neat and all but I still can't get .desktop files to work. – tatsu Mar 2 '19 at 10:21
  • for me it doesn't work. it doesn't remeber password. dors this work with solaris? – tatsu Mar 4 '19 at 8:16

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.