Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timeout argument to ssh_connect() nasl function #631

Merged
merged 2 commits into from
Dec 14, 2020

Conversation

jjnicola
Copy link
Member

@jjnicola jjnicola commented Dec 11, 2020

What:
Add timeout argument to ssh_connect() nasl function to set the connection timeout in seconds

Why:
Some ssh server take too long to return the prompt for the password

How:
As I didn't have a ssh server with the issue, I have used the paramiko server demo and added some sleep() before returning the prompt. That simulates the issue in the server side. Then, I used the next nasl script:

openvas-nasl -X -B -d -i /home/jnicola/install/var/lib/openvas/plugins -t localhost ssh_timeout.nasl

login = "robey";
password = "foo";
port = 2200;

#Sockets
  soc = open_sock_tcp( port );
  if( ! soc ) exit( 0 );
  display ("socket opened:",soc);

#Use the new timeout option. It must be greather than the sleep set in the demo server
  sess = ssh_connect( socket:soc, timeout:15 );
  display("session: ", sess);

if( ! sess )
  return 0;

if( ssh_userauth( sess, login:login, password:password ) ) {
  ssh_disconnect( sess );
  last_sess = 0;
  return 0;
}

Checklist:

nasl/nasl_ssh.c Show resolved Hide resolved
nasl/nasl_ssh.c Outdated Show resolved Hide resolved
ArnoStiefvater
ArnoStiefvater previously approved these changes Dec 14, 2020
nasl/nasl_ssh.c Outdated Show resolved Hide resolved
nasl/nasl_ssh.c Outdated Show resolved Hide resolved
Copy link
Member

@cfi-gb cfi-gb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving the text / description changes.

@ArnoStiefvater ArnoStiefvater merged commit efa3577 into greenbone:openvas-20.08 Dec 14, 2020
@jjnicola jjnicola deleted the ssh-timeout branch December 14, 2020 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants