mirror of
https://github.com/tmate-io/tmate.git
synced 2026-01-23 02:24:06 +00:00
ssh-client: Always try to do none auth first!
Per spec a SSH client needs to try the 'none' auth first. This is also the case with libssh as a client and we exchange important messages with a server that way. For example SSH2_MSG_EXT_INFO for rsa-sha2-512.
This commit is contained in:
parent
4e7caeb536
commit
bbb3f2d28d
2 changed files with 19 additions and 4 deletions
|
|
@ -344,11 +344,24 @@ static void on_ssh_client_event(struct tmate_ssh_client *client)
|
|||
*/
|
||||
tmate_debug("Connected to %s", client->server_ip);
|
||||
on_ssh_auth_server_complete(client);
|
||||
client->state = SSH_AUTH_CLIENT;
|
||||
client->state = SSH_AUTH_CLIENT_NONE;
|
||||
|
||||
/* fall through */
|
||||
case SSH_AUTH_CLIENT_NONE:
|
||||
switch(ssh_userauth_none(session, NULL)) {
|
||||
case SSH_AUTH_ERROR:
|
||||
kill_ssh_client(client, "Auth error: %s", ssh_get_error(session));
|
||||
return;
|
||||
case SSH_AUTH_AGAIN:
|
||||
return;
|
||||
case SSH_AUTH_SUCCESS:
|
||||
goto auth_success;
|
||||
default:
|
||||
client->state = SSH_AUTH_CLIENT_PUBKEY;
|
||||
}
|
||||
|
||||
case SSH_AUTH_CLIENT:
|
||||
/* fall through */
|
||||
case SSH_AUTH_CLIENT_PUBKEY:
|
||||
client->tried_passphrase = client->tmate_session->passphrase;
|
||||
switch (ssh_userauth_autopubkey(session, client->tried_passphrase)) {
|
||||
case SSH_AUTH_AGAIN:
|
||||
|
|
@ -372,7 +385,8 @@ static void on_ssh_client_event(struct tmate_ssh_client *client)
|
|||
kill_ssh_client(client, "Auth error: %s", ssh_get_error(session));
|
||||
return;
|
||||
case SSH_AUTH_SUCCESS:
|
||||
tmate_debug("Auth successful");
|
||||
auth_success:
|
||||
tmate_debug("Auth successful with 'publickey'");
|
||||
client->state = SSH_OPEN_CHANNEL;
|
||||
|
||||
client->channel = channel = ssh_channel_new(session);
|
||||
|
|
|
|||
3
tmate.h
3
tmate.h
|
|
@ -106,7 +106,8 @@ enum tmate_ssh_client_state_types {
|
|||
SSH_INIT,
|
||||
SSH_CONNECT,
|
||||
SSH_AUTH_SERVER,
|
||||
SSH_AUTH_CLIENT,
|
||||
SSH_AUTH_CLIENT_NONE,
|
||||
SSH_AUTH_CLIENT_PUBKEY,
|
||||
SSH_OPEN_CHANNEL,
|
||||
SSH_BOOTSTRAP,
|
||||
SSH_READY,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue