I’m trying connect to ssh server using custom location (not in ~/.ssh) private key
key = File.open!("/private/tmp/.ssh/id_rsa")
known_hosts = File.open!("/private/tmp/.ssh/known_hosts")
cb =
SSHClientKeyAPI.with_options(
identity: key,
known_hosts: known_hosts,
silently_accept_hosts: true
)
# IO.inspect(cb)
context =
SSHKit.context("x230.local",
port: 22,
user: "username",
key_cb: cb,
#password: "pass",
)
SSHKit.run(context, "whoami")
But get result:
16:34:28.579 [notice] Erlang SSH :client version: 5.0.1 (OpenSSL 1.1.1s 1 Nov 2022).
Address: 192.168.100.182:51263
Peer server version: ~c"SSH-2.0-OpenSSH_9.2p1 Debian-2"
Peer address: 192.168.100.186:22
Disconnects with code = 14 [RFC4253 11.1]: Unable to connect using the available authentication methods
State = {userauth,client}
Module = ssh_fsm_userauth_client, Line = 96.
Details:
User auth failed for: "username"
I also try using :ssh.connect
but got same result.
Note:
- I can connect using password authentication
- I can connect with key using ssh cli
ssh username@host -i /private/tmp/.ssh/id_rsa