[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ssh_user_auth_none Permission denied
[Thread Prev] | [Thread Next]
- Subject: Re: ssh_user_auth_none Permission denied
- From: Tilo Eckert <tilo.eckert@xxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Fri, 18 Mar 2016 13:07:06 +0100
- To: libssh@xxxxxxxxxx
For SSH2, you must set the username before connecting via ssh_options_set(session, SSH_OPTIONS_USER, username); The username parameter of ssh_userauth_try_publickey() and all other functions must be NULL. ssh_userauth_none() will never return SSH_AUTH_SUCCESS unless the SSH server does not require any authentication at all. It is only useful to query the available authentication methods and usually returns SSH_AUTH_DENIED or SSH_AUTH_ERROR if there was a real error. Best regards Tilo Am 18.03.2016 um 12:27 schrieb Sruthi Mohan (RBEI/EIA1): > Dear All, > > I am trying to connect to the server using ssh. > I get Access denied for ssh_user_auth_none. Authentication that can > continue Public key > As per ssh_userauth_list list PUBLIC KEY authentication is valid > > Post that ssh_userauth_try_publickeyand ssh_pki_import_pubkey_filealso > fails. Kindly let me know the possible reason failure > > > Attached code below > > intmain(intargc,char*argv[]) > { > QCoreApplication a(argc, argv); > ssh_session my_ssh_session; > int verbosity = SSH_LOG_PROTOCOL; > int port = 155; > my_ssh_session = ssh_new(); > if (my_ssh_session == NULL) > { > exit(-1); > } > ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, myip); > ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity); > ssh_options_set(my_ssh_session, SSH_OPTIONS_PORT, &port); > > int rc = ssh_connect(my_ssh_session); > if (rc != SSH_OK) > { > qDebug()<<"Error connecting tohost:"<<ssh_get_error(my_ssh_session); > exit(-1); > } > rc=verify_knownhost(my_ssh_session); > rc = ssh_userauth_none(my_ssh_session, NULL); > if (rc != SSH_AUTH_SUCCESS) { > qDebug()<<"Error connecting to localhost: > %s\n"<<ssh_get_error(my_ssh_session); > // return rc; > } > int method = ssh_userauth_list(my_ssh_session, NULL); > > if (method & SSH_AUTH_METHOD_NONE) > { > qDebug()<<"Authenticate None"; > } > if (method & SSH_AUTH_METHOD_PUBLICKEY) > { > qDebug()<<"Authenticate pubkey"; > } > if (method & SSH_AUTH_METHOD_INTERACTIVE) > { > qDebug()<<"Authenticate keyboard"; > } > if (method & SSH_AUTH_METHOD_PASSWORD) > { > qDebug()<<"Authenticate password"; > } > > if(ssh_pki_import_pubkey_file(PublickeyFile.toStdString().c_str(),&pubkey)!=SSH_OK) > { > qDebug()<<"Failed to import the key"; > } > if(ssh_userauth_try_publickey(my_ssh_session,"S3DDM",pubkey)==SSH_ERROR) > { > qDebug()<<"Failed to import the key"; > } > > > ssh_free(my_ssh_session); > ssh_disconnect(my_ssh_session); > > return a.exec(); > } > > > Best regards > > *Sruthi Mohan * > *RBEI/EIA1* > > Tel. +91(80)6783-7826 > >
Re: ssh_user_auth_none Permission denied | Andreas Schneider <asn@xxxxxxxxxxxxxx> |
ssh_user_auth_none Permission denied | "Sruthi Mohan (RBEI/EIA1)" <Sruthi.Mohan@xxxxxxxxxxxx> |