我正在使用elixir,其中我必须在收到http请求并验证其内容后建立ssh连接的项目。我正在尝试使用以下命令建立ssh连接:
:ssh.start
{:ok, conn} = :ssh.connect('o5108005855.v4.s5.ams.boa.io', 22, [ {:user,<user_name>},{:silently_accept_hosts, true} ], 5000)
我被要求输入ssh密码,当我这样做时,我得到:undefined function <password>/0
。如果有人遇到类似问题,请分享您的解决方案。
经过一段时间的不活动后,我得到了:
17:04:01.359 [error] [69, 114, 108, 97, 110, 103, 32, 115, 115, 104, 32, 99, 111, 110, 110, 101, 99, 116, 105, 111, 110, 32, 104, 97, 110, 100, 108, 101, 114, 32, 102, 97, 105, 108, 101, 100, 32, 119, 105, 116, 104, 32, 114, 101, 97, 115, 111, 110, 58, '\n', ...]
17:04:01.419 [error] ** State machine #PID<0.291.0> terminating
** Last event = {:internal,
{:ssh_msg_userauth_failure, 'publickey,password,keyboard-interactive', false}}
** When server state = [data: [{'State',
[starter: #PID<0.288.0>, auth_user: 'o5108005855.intern',
connection_state: {:connection, [], 127015, [], 0, :undefined, :undefined,
:undefined,
[user_pid: #PID<0.288.0>, host: '50.31.233.142',
user: 'o5108005855.intern', silently_accept_hosts: true], :undefined,
:undefined, :undefined, :undefined}, latest_channel_id: 0,
idle_timer_ref: :infinity, idle_timer_value: :infinity,
transport_protocol: :tcp, transport_cb: :gen_tcp,
transport_close_tag: :tcp_closed,
ssh_params: [role: :client,
peer: {'50.31.233.142', {{50, 31, 233, 142}, 22}}, c_vsn: {2, 0},
s_vsn: {2, 0}, c_version: 'SSH-2.0-Erlang/4.3',
s_version: 'SSH-2.0-OpenSSH_7.2', algorithms: :undefined,
kex: :"ecdh-sha2-nistp256", hkey: :"ecdsa-sha2-nistp256",
key_cb: :ssh_file, io_cb: :ssh_io, send_mac: :"hmac-sha2-256",
recv_mac: :"hmac-sha2-256", encrypt: :"aes256-ctr", encrypt_block_size: 16,
decrypt: :"aes256-ctr", decrypt_block_size: 16, compress: :none,
decompress: :none, c_lng: :none, s_lng: :none, user_ack: true,
timeout: :infinity,
opts: [user_pid: #PID<0.288.0>, host: '50.31.233.142',
user: 'o5108005855.intern', silently_accept_hosts: true],
send_sequence: 5, recv_sequence: 5, random_length_padding: 255,
user: 'o5108005855.intern', service: 'ssh-connection',
userauth_quiet_mode: false, userauth_methods: :none,
userauth_supported_methods: 'publickey,keyboard-interactive,password',
kb_tries_left: 0,
userauth_preference: [{'publickey', :ssh_auth, :publickey_msg,
[:"ssh-rsa"]}, {'publickey', :ssh_auth, :publickey_msg, ...},
{'publickey', :ssh_auth, ...}, {'publickey', ...}, {...}, ...],
pwdfun_user_state: :undefined, authenticated: false],
socket: #Port<0.5547>, undecrypted_packet_length: :undefined,
last_size_rekey: 0, event_queue: []]}]]
** Reason for termination = :error::badarg
** Callback mode = :handle_event_function
** Queued = [internal: :prepare_next_packet]
** Stacktrace =
** [{:unicode, :characters_to_binary, ["$gen_cast": :data_size], []},
{:ssh_auth, :password_msg, 1, [file: 'ssh_auth.erl', line: 89]},
{:ssh_auth, :userauth_request_msg, 1, [file: 'ssh_auth.erl', line: 158]},
{:ssh_connection_handler, :handle_event, 4,
[file: 'ssh_connection_handler.erl', line: 772]},
{:gen_statem, :loop_event, 9, [file: 'gen_statem.erl', line: 880]},
{:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 247]}]