Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
SSH Socket Try 1
require 'fiddle'
require 'socket'
libssh = Fiddle.dlopen('/usr/lib/')
ssh_bind =['ssh_bind_new'],[],Fiddle::TYPE_LONG_LONG)
ssh_session =['ssh_new'],[],Fiddle::TYPE_LONG_LONG)
ssh_bind_listen =['ssh_bind_listen'],[Fiddle::TYPE_LONG_LONG],Fiddle::TYPE_INT)
ssh_bind_accept =['ssh_bind_accept'],[Fiddle::TYPE_LONG_LONG,Fiddle::TYPE_LONG_LONG],Fiddle::TYPE_CHAR)
ssh_get_error =['ssh_get_error'],[Fiddle::TYPE_LONG],Fiddle::TYPE_CHAR)
sshbind =
puts "sshbind pointer: #{sshbind}"
sshsession =
puts "sshsession pointer: #{sshsession}"
result =
if result.to_i < 0
puts "Error: #{}"
puts "ssh_bind_listen should return 0: #{result}"
sshaccept =, sshsession)
puts "sshaccept should return 'SSH_OK': #{sshaccept}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment