Using a variable's value as password for scp, ssh etc. instead of prompting for user input every time

前端 未结 10 1586
独厮守ぢ
独厮守ぢ 2020-12-03 03:38

AFAIK, the commands ssh or scp do not have/take a password parameter. Otherwise I could keep the password in a shell variable and probably get rid

10条回答
  •  南笙
    南笙 (楼主)
    2020-12-03 04:37

    For password authentication, as you mentioned in you description, you can use "sshpass". On Ubuntu, you can install as "sudo apt-get install sshpass".

    For public/private key-pair base authentication,

    • First generate keys using, "ssh-keygen"
    • Then copy your key to the remote machine, using "ssh-copy-id username@remote-machine"

    Once copied, the subsequent logins should not ask for password.

提交回复
热议问题