Last active
September 19, 2019 07:42
-
-
Save scarybot/1dda918cacffa9594396f3a6862b4f0c to your computer and use it in GitHub Desktop.
Get a list of allowed SSH auth methods (for Ryan)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/ssh' | |
transport_session = Net::SSH::Transport::Session.new('ryans-server.com') | |
transport_session.send_message(transport_session.service_request("ssh-userauth")) | |
auth_session = Net::SSH::Authentication::Session.new(transport_session) | |
auth_session.expect_message(Net::SSH::Transport::Constants::SERVICE_ACCEPT) | |
transport_session.send_message(Net::SSH::Authentication::Methods::Publickey.new(transport_session).userauth_request(false, false, false)) | |
allowed_auth_methods = transport_session.next_message.instance_variable_get('@named_elements')[:authentications].split(',') | |
puts allowed_auth_methods.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment