ssh key passwordless using bash

前端 未结 3 810
深忆病人
深忆病人 2020-12-22 11:27

I would like to use ssh key authentication. I have a file that contains:

ip location

ip location

etc

i have a bash script as follow :

相关标签:
3条回答
  • 2020-12-22 11:49

    If you want to open an ssh session using your keys without having to putt the password I think that this is what you are looking for: http://www.linuxproblem.org/art_9.html

    0 讨论(0)
  • 2020-12-22 11:52

    If you don't want to use a password and security is not important, another solution is to use sshpass.

    This is generally not a good idea, specially in secure environments, but in some situations it can help.

    sshpass -p raspberry ssh pi@192.168.0.145
    

    this can be combined with

    ssh -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no pi@192.168.0.145
    

    to avoid confirmation questions that prevent automated scripting from happening.

    Again, only use this in development systems where different machines share an IP and security is not important.

    https://ownyourbits.com/2017/02/22/easy-passwordless-ssh-with-sshh/

    0 讨论(0)
  • 2020-12-22 11:58

    Execute the following command from your host machine as the usual user. This will generate a public-private key for this user on that host.

    ssh-keygen
    

    The keys will by default be created under ~/.ssh and usually named as id_rsa (private key) id_rsa.pub (public key) Now the public key can be copied to any number of remote computers and all further secure log-ins to those hosts will not prompt for the password.

    ssh-copy-id user@machine
    
    0 讨论(0)
提交回复
热议问题