alexcrichton / ssh2-rs

Rust bindings for libssh2
https://docs.rs/ssh2
Apache License 2.0
485 stars 147 forks source link

Add Session.userauth_banner #277

Open ScottCUSA opened 1 year ago

ScottCUSA commented 1 year ago

Implements #275

Add a method retrieve the ssh userauth banner. Returns the SSH_MSG_USERAUTH_BANNER message sent by the server. Will return [Session(-50)] missing userauth banner if user auth hasn't yet been attempted.

  let auth_methods = session.auth_methods(user)?;

  if let Some(ret) = session.userauth_banner()? {
      println!("{}", ret);
  };    

Example:

---------  AT&T IP Services Route Monitor  -----------

The information available through <snipped> is offered
by AT&T's Internet engineering organization to the Internet community.

This router maintains eBGP peerings with customer-facing routers
throughout the AT&T IP Services Backbone:
...
yodaldevoid commented 1 year ago

This seems good so far. Would you be able to add a test?

ScottCUSA commented 1 year ago

This seems good so far. Would you be able to add a test?

I haven't been able to validate the test, but I think it should be good. There might be a path issue to the banner file.