Simple Elixir implementation for the Erlang :ssh_client_key_api
behavior, to
make it easier to specify SSH keys and known_hosts
files independently of
any particular user's home directory.
By itself, :ssh_client_key_api
does not provide SSH functionality, it only adds
a way to send private key information to an SSH connection. It is meant to be
used alongside an SSH library such as :ssh
, SSHex
, SSHKit
, or the like.
The package can be installed by adding :ssh_client_key_api
to your list of
dependencies in mix.exs
:
def deps do
[
{:ssh_client_key_api, "~> 0.2.0"}
]
end
SSHClientKeyAPI
is meant to primarily be used via the convenience function
with_options/1
. See with_options/1
for full list of available options.
key = File.open!("path/to/keyfile.pem")
known_hosts = File.open!("path/to/known_hosts")
cb = SSHClientKeyAPI.with_options(
identity: key,
known_hosts: known_hosts,
silently_accept_hosts: true
)
The result can then be passed as an option when creating an SSH connection.
Using SSHKit.SSH.connect/2
:
connection = SSHKit.SSH.connect("example.com", key_cb: cb)
Or through SSHKit.context/2
:
context = SSHKit.context("example.com", key_cb: cb)
Copyright (c) 2017 Lab Zero Innovations Inc.
This library is MIT licensed. See the LICENSE for details.