Script for ssh automatic login to a specific port

6,161

For automatic login, the way to go is using key-based authentication.

A nice tutorial here

You can then use the default one (the one in the ~/.ssh/id_rsa ) or use another key passing -i MyKeyFile parameter to ssh.

Share:
6,161

Related videos on Youtube

sam
Author by

sam

Updated on September 18, 2022

Comments

  • sam
    sam over 1 year

    So currently, the "traditional" way to connect through SSH is the following one:

    ssh USERNAME@HOST -p PORT
    

    I would like to create a script in which I will include all the appropriate information (username, password, host, port) and when I run it, it will connect automatically leading me to the shell of the host machine.

    I don't care about the language you will use (e.g. Python, Perl...). I have tried to create it using Expect but unfortunately it didn't work for me.

    • lese
      lese over 8 years
      is for your self? create a bashrc alias
    • smw
      smw over 8 years
      A better option might be to use the user's ~/.ssh/config file + key-based authentication
    • lese
      lese over 8 years
      you are right, I didn't think about it