Bash: controlling SSH

后端 未结 8 2088
执念已碎
执念已碎 2020-12-03 15:26

I have this bash file, which asks for IP, password, etc. for OpenSSH to a device.

Now, if i use ssh root@ip, i have to enter the password. This is reall

相关标签:
8条回答
  • 2020-12-03 16:26

    Many tools to go great lengths to prevent what you are doing. I recommend using ssh public keys to solve this problem instead of passwords.

    The big alternative is to write your own modified ssh client based on the open source so as to take control of the password management.

    Oh, well, I forgot. You can probably outsmart this with a pty, since then /dev/tty will be what you control. expect might help you with this.

    0 讨论(0)
  • 2020-12-03 16:26

    Use ssh-keygen to create a public key for your machine, then copy your local ~/.ssh/id_rsa.pub or ~/.ssh/identity.pub to the remote system, in ~/.ssh/authorized_keys.

    You may need to tighten the permissions on the authorized_keys file: chmod 600

    0 讨论(0)
提交回复
热议问题