1

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@192.168.1.12 -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@192.168.1.12 -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]
Version=1.0
Type=Application
Terminal=true
Exec=bash -c 'exec bash -i <<<"connectme"'
Name=connectme
Comment=connectme
Icon=/home/user/.local/share/icons/debian.png

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.

tatsu
  • 3,346

1 Answers1

0

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.

waltinator
  • 37,856