SSH
Msf::Exploit::Remote::SSH provides shared settings for Net::SSH connections. Its implementation is lib/msf/core/exploit/remote/ssh.rb. Options come through Msf::Exploit::Remote::SSH::Options.
include
Section titled “include”include Msf::Exploit::Remote::SSH# Or include only Optionsinclude Msf::Exploit::Remote::SSH::OptionsMain helpers
Section titled “Main helpers”def ssh_client_defaults # non_interactive, verify_host_key: :never, proxy factory, etc.end
factory = ssh_socket_factoryA connection example:
opts = ssh_client_defaults.merge( auth_methods: ['password', 'keyboard-interactive'], port: datastore['RPORT'], password: pass)ssh = Net::SSH.start(ip, user, opts)ssh.exec!('id')Patterns
Section titled “Patterns”Login scanner (auxiliary)
Section titled “Login scanner (auxiliary)”AuthBrute + Scanner + SSH Options. Record a successful login with create_credential_and_login and create a session if needed.
Existing example: modules/auxiliary/scanner/ssh/ssh_login.rb
Command-execution exploit
Section titled “Command-execution exploit”After authentication, use exec! to send CmdStager fragments or a payload.
Existing example: modules/exploits/multi/ssh/sshexec.rb (execute_command uses ssh_socket.exec!)
Interactive session
Section titled “Interactive session”Some targets support an interactive channel through a payload or session such as generic/ssh/interact. See SSH / WinRM Login for operational steps.
Example options
Section titled “Example options”| Option | Meaning |
|---|---|
RPORT | Usually 22 |
SSH_TIMEOUT / SSH_DEBUG / SSH_IDENT | Provided by the Options mixin (names may vary by version) |
KEY_PATH / PRIVATE_KEY | Public-key authentication (module-dependent) |
Check the actual option names with show options and show advanced.

