Closed matlabrui-code closed 1 year ago
There are at least 3 solutions to this problem. The ideal solution would be for you to use a non-interactive authentication method, publickey
. That is what scripted SSH connections are supposed to use for this exact reason.
Then, you can avoid this question by having the host key stored in your known_hosts
in advance. I am not sure what is the easiest way of doing that but I am sure you could find something with a quick search. Probably, ssh(1)
could be configured to perform this.
Lastly, if you do not mind changing the code of the CLI, you can define your own callback for verifying the host key. It is set by the function nc_client_ssh_set_auth_hostkey_check_clb()
.
This is a bit "tricky" because netopeer2-cli
is using libssh
internally. Now, libssh
implements some bits which make it similar to OpenSSH's ssh(1)
binary, but it only goes half way there. For example, OpenSSH has a ton of options that you can use for, say, configuring whether the host keys are checked at all, and where to store them. There's no control over that using libssh
(unless one writes some C code).
In netconf-cli
we decided to avoid this problem by simply forking and launching ssh(1)
, and talking to that over a pipe. That way we delegate 100% of SSH communication (and authentication, and option handling, and...) to the existing systemwide or user-specific configuration, and we did not have to reinvent any new wheels.
Hi all, I have finished this issue right now. Actually, when the "The authenticity of the host 'localhost' cannot be established." appeared, and I clicked "yes". My linux system root path would generated a public key file called "known_keys". So I stored this key file, and write a script ,when system restart my script would copy the key file to the root path, then when I login to netopeer2-cli , the authentication info would not appeared.
Thank your all for your kind suggestion, have a good day!
Hi, I wan to use shell script to realize login neotpeer2-cli first time. But after I use the "connect" command , it will require me to put "yes" on the terminal.
Here is my script as below:
"yes“ would not work, how can I let the "yes" send to the netopeer2-cli ?