15

I have many remote machines I need to log in. I need somehow store connection parameters because it is too boring enter them manually. Also I prefer to store password in these shortcuts. Software similar MTPuTTY that runs under windows would would solve my problem in Ubuntu.

How to solve this problem?

3
  • 1
    Related: Permanently store addresses when using SSH. Use key-based authentication if possible. Apr 6, 2016 at 13:54
  • Which command line parameters do you mean specifically? If it's just passwordless login you could use SSH keys, so a simple ssh (user@)machinename would be enough.
    – Pabi
    Apr 6, 2016 at 14:30
  • 1
    Another thing you might consider is that if it's actually just the 'boring' aspect, you can probably find it in your command history and just use a ! command to execute it again. try history | grep ssh
    – infixed
    Apr 6, 2016 at 15:58

2 Answers 2

19

You can do a lot using .ssh/config file. It would allow you to replace this:

ssh [email protected] -p 22000

with:

ssh dev

to do so you have to add the following lines at the end of the .ssh/config (create it if does not exist)

Host dev
    HostName dev.example.com
    Port 22000
    User fooey

Concerning the storage of your credentials, I strongly advise you to use key authentification instead of password based. You can create them either with a GUI or with your terminal.

GUI

open Seahorse, select File > New, then Secure Shell Key and let the interface guide you

Terminal Create you RSA key pair:

ssh-keygen -t rsa

Store the Keys and Passphrase:

Enter file in which to save the key (/home/demo/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):

Copy the Public Key

ssh-copy-id [email protected]

Sources:

5

If you wanted to, you could make short shell scripts to launch your ssh sessions, then execute them either as s executable ( chmod o+x), or using the dot . command

Like make a file ~/ssh2hostA.sh

#!/bin/sh
sshpass -p 'yourpassword' ssh user@hostA

then start it with

. ~/ssh2hostA.sh

Which is not a good thing to do because not only do you have passwords in cleartext scattered in your files, but people will probably be able to see the password in the w command. ( and top, and /proc)

Really, you should be using ssh host keys for this.

Really.

2
  • Strange, if I run souch file in command line like ./ttt it makes nothing - no messages and no ssh login
    – vico
    Apr 6, 2016 at 14:38
  • not sure how you made the file. You probably can't just go ./filename unless you set it's execution permission with chmod. I suggested 'dotting' it. . filename tells bash to read commands from a file. Note the space between the dot and the filename. Of course you can always go sh -x filename to gain some visibility about what it is doing when you run it
    – infixed
    Apr 6, 2016 at 15:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .