-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | libssh bindings -- -- libssh bindings @package libssh @version 0.1.0.0 -- | See the libssh topics for a reference. module Network.LibSSH.Core data {-# CTYPE "libssh/libssh.h" "struct ssh_key_struct" #-} SSHKeyStruct type SSHKey = Ptr SSHKeyStruct data {-# CTYPE "libssh/libssh.h" "struct ssh_session_struct" #-} SSHSessionStruct type SSHSession = Ptr SSHSessionStruct data {-# CTYPE "libssh/libssh.h" "struct ssh_channel_struct" #-} SSHChannelStruct type SSHChannel = Ptr SSHChannelStruct data {-# CTYPE "libssh/sftp.h" "struct sftp_session_struct" #-} SFTPSessionStruct type SFTPSession = Ptr SFTPSessionStruct data {-# CTYPE "libssh/sftp.h" "struct sftp_file_struct" #-} SFTPFileStruct type SFTPFile = Ptr SFTPFileStruct data {-# CTYPE "libssh/sftp.h" "struct sftp_dir_struct" #-} SFTPDirStruct type SFTPDir = Ptr SFTPDirStruct data {-# CTYPE "libssh/sftp.h" "struct sftp_attributes_struct" #-} SFTPAttributesStruct type SFTPAttributes = Ptr SFTPAttributesStruct data {-# CTYPE "libssh/sftp.h" "struct sftp_statvfs_struct" #-} SFTPStatvfsStruct type SFTPStatsvfs = Ptr SFTPStatvfsStruct type SSHAuthCallback = FunPtr (CString -> CString -> CSize -> CInt -> CInt -> Ptr CChar -> CInt) type SSHOptionCode = CInt sshOptionsHost :: SSHOptionCode sshOptionsPort :: SSHOptionCode sshOptionsPortStr :: SSHOptionCode sshOptionsFd :: SSHOptionCode sshOptionsBindaddr :: SSHOptionCode sshOptionsUser :: SSHOptionCode sshOptionsSSHDir :: SSHOptionCode sshOptionsKnownhosts :: SSHOptionCode sshOptionsIdentity :: SSHOptionCode sshOptionsAddIdentity :: SSHOptionCode sshOptionsTimeout :: SSHOptionCode sshOptionsTimeoutUsec :: SSHOptionCode type SSHAuthMethodCode = CInt sshAuthMethodUnknown :: SSHAuthMethodCode sshAuthMethodNone :: SSHAuthMethodCode sshAuthMethodPassword :: SSHAuthMethodCode sshAuthMethodPublickey :: SSHAuthMethodCode sshAuthMethodHostbased :: SSHAuthMethodCode sshAuthMethodInteractive :: SSHAuthMethodCode sshAuthMethodGssapiMic :: SSHAuthMethodCode type SSHKeyType = CInt sshKeytypeUnknown :: SSHKeyType sshKeytypeRsa :: SSHKeyType sshKeytypeRsa1 :: SSHKeyType sshKeytypeEcdsa :: SSHKeyType sshKeytypeEd25519 :: SSHKeyType sftp_new :: SSHSession -> IO SFTPSession sftp_new_channel :: SSHSession -> SSHChannel -> IO SFTPSession sftp_free :: SFTPSession -> IO () sftp_init :: SFTPSession -> IO CInt sftp_get_error :: SFTPSession -> IO CInt sftp_extensions_get_count :: SFTPSession -> IO CInt sftp_extensions_get_name :: SFTPSession -> CUInt -> IO CString sftp_extensions_get_data :: SFTPSession -> CUInt -> IO CString sftp_extension_extension_supported :: SFTPSession -> CString -> CString -> IO CInt sftp_opendir :: SFTPSession -> CString -> IO SFTPDir sftp_readdir :: SFTPSession -> SFTPDir -> IO SFTPAttributes sftp_dir_eof :: SFTPDir -> IO CInt sftp_stat :: SFTPSession -> CString -> IO SFTPAttributes sftp_lstat :: SFTPSession -> CString -> IO SFTPAttributes sftp_fstat :: SFTPFile -> IO SFTPAttributes sftp_attributes_free :: SFTPAttributes -> IO () sftp_closedir :: SFTPDir -> IO CInt sftp_close :: SFTPFile -> IO CInt sftp_open :: SFTPSession -> CString -> CInt -> CInt -> IO SFTPFile sftp_file_set_nonblocking :: SFTPFile -> IO () sftp_file_set_blocking :: SFTPFile -> IO () sftp_read :: SFTPFile -> CString -> CSize -> IO CInt sftp_async_read_begin :: SFTPFile -> CUInt -> IO CInt sftp_async_read :: SFTPFile -> CString -> CUInt -> CUInt -> IO CInt sftp_write :: SFTPFile -> CString -> CSize -> IO CInt sftp_seek :: SFTPFile -> CUInt -> IO CInt sftp_seek64 :: SFTPFile -> CULLong -> IO CInt sftp_tell :: SFTPFile -> IO CUInt sftp_tell64 :: SFTPFile -> IO CULLong sftp_rewind :: SFTPFile -> IO () sftp_unlink :: SFTPSession -> CString -> IO CInt sftp_rmdir :: SFTPSession -> CString -> IO CInt sftp_mkdir :: SFTPSession -> CString -> CInt -> IO CInt sftp_rename :: SFTPSession -> CString -> CString -> IO CInt sftp_setstat :: SFTPSession -> CString -> SFTPAttributes -> IO CInt sftp_chown :: SFTPSession -> CString -> CInt -> CInt -> IO CInt sftp_chmod :: SFTPSession -> CString -> CInt -> IO CInt sftp_symlink :: SFTPSession -> CString -> CString -> IO CInt sftp_readlink :: SFTPSession -> CString -> IO CString sftp_fsync :: SFTPFile -> IO CInt ssh_init :: IO CInt ssh_finalize :: IO CInt ssh_set_agent_channel :: SSHSession -> SSHChannel -> IO CInt ssh_set_agent_socket :: SSHSession -> CInt -> IO CInt ssh_userauth_list :: SSHSession -> CString -> IO SSHAuthMethodCode ssh_userauth_none :: SSHSession -> CString -> IO CInt ssh_userauth_try_publickey :: SSHSession -> CString -> SSHKey -> IO CInt ssh_userauth_publickey :: SSHSession -> CString -> SSHKey -> IO CInt ssh_userauth_agent :: SSHSession -> CString -> IO CInt ssh_userauth_publickey_auto :: SSHSession -> CString -> CString -> IO CInt ssh_userauth_password :: SSHSession -> CString -> CString -> IO CInt ssh_userauth_gssapi :: SSHSession -> IO CInt ssh_channel_new :: SSHSession -> IO SSHChannel ssh_channel_open_session :: SSHChannel -> IO CInt ssh_channel_free :: SSHChannel -> IO () ssh_channel_send_eof :: SSHChannel -> IO CInt ssh_channel_close :: SSHChannel -> IO CInt ssh_channel_write :: SSHChannel -> CString -> CUInt -> IO CInt ssh_channel_is_open :: SSHChannel -> IO CInt ssh_channel_is_closed :: SSHChannel -> IO CInt ssh_channel_is_eof :: SSHChannel -> IO CInt ssh_channel_set_blocking :: SSHChannel -> CInt -> IO () ssh_channel_request_pty :: SSHChannel -> IO CInt ssh_channel_request_shell :: SSHChannel -> IO CInt ssh_channel_request_subsystem :: SSHChannel -> CString -> IO CInt ssh_channel_request_sftp :: SSHChannel -> IO CInt ssh_channel_request_auth_agent :: SSHChannel -> IO CInt ssh_channel_request_exec :: SSHChannel -> CString -> IO CInt ssh_channel_request_send_signal :: SSHChannel -> CString -> IO CInt ssh_channel_request_send_break :: SSHChannel -> CUInt -> IO CInt ssh_channel_read :: SSHChannel -> CString -> CUInt -> CInt -> IO CInt ssh_channel_read_timeout :: SSHChannel -> CString -> CUInt -> CInt -> CInt -> IO CInt ssh_channel_read_nonblocking :: SSHChannel -> CString -> CUInt -> CInt -> IO CInt ssh_channel_poll :: SSHChannel -> CInt -> IO CInt ssh_channel_poll_timeout :: SSHChannel -> CInt -> CInt -> IO CInt ssh_channel_get_session :: SSHChannel -> IO SSHSession ssh_channel_get_exit_status :: SSHChannel -> IO CInt ssh_get_error :: Ptr () -> IO CString ssh_get_error_code :: Ptr () -> IO CInt ssh_set_log_level :: CInt -> IO CInt ssh_get_log_level :: IO CInt ssh_version :: CInt -> IO CString ssh_key_new :: IO SSHKey ssh_key_free :: SSHKey -> IO () ssh_key_type :: SSHKey -> IO SSHKeyType ssh_key_type_from_name :: CString -> IO SSHKeyType ssh_key_is_public :: SSHKey -> IO CInt ssh_key_is_private :: SSHKey -> IO CInt ssh_pki_import_privkey_base64 :: CString -> CString -> SSHAuthCallback -> Ptr () -> Ptr SSHKey -> IO CInt ssh_pki_import_privkey_file :: CString -> CString -> SSHAuthCallback -> Ptr () -> Ptr SSHKey -> IO CInt ssh_pki_import_pubkey_base64 :: CString -> SSHKeyType -> Ptr SSHKey -> IO CInt ssh_pki_import_pubkey_file :: CString -> Ptr SSHKey -> IO CInt ssh_pki_import_cert_base64 :: CString -> SSHKeyType -> Ptr SSHKey -> IO CInt ssh_pki_import_cert_file :: CString -> Ptr SSHKey -> IO CInt ssh_pki_generate :: SSHKeyType -> CInt -> Ptr SSHKey -> IO CInt ssh_pki_export_privkey_to_pubkey :: SSHKey -> Ptr SSHKey -> IO CInt ssh_service_request :: SSHSession -> CString -> IO CInt ssh_connect :: SSHSession -> IO CInt ssh_get_issue_banner :: SSHSession -> IO CString ssh_get_openssh_version :: SSHSession -> IO CInt ssh_copyright :: IO CString ssh_disconnect :: SSHSession -> IO () ssh_options_copy :: SSHSession -> Ptr SSHSession -> IO CInt ssh_options_set :: SSHSession -> SSHOptionCode -> Ptr () -> IO CInt ssh_options_parse_config :: SSHSession -> CString -> IO CInt ssh_new :: IO SSHSession ssh_free :: SSHSession -> IO () ssh_silent_disconnect :: SSHSession -> IO () ssh_set_blocking :: SSHSession -> CInt -> IO () ssh_is_blocking :: SSHSession -> IO CInt ssh_blocking_flush :: SSHSession -> CInt -> IO CInt ssh_is_connected :: SSHSession -> IO CInt ssh_get_status :: SSHSession -> IO CInt ssh_get_poll_flags :: SSHSession -> IO CInt ssh_get_disconnect_message :: SSHSession -> IO CString ssh_get_version :: SSHSession -> IO CInt ssh_send_ignore :: SSHSession -> CString -> IO CInt ssh_send_debug :: SSHSession -> CString -> CInt -> IO CInt -- | See the libssh documentation for its API reference and a usage -- tutorial. -- -- These bindings are intended to be simple, predictable, and stay close -- to the original library, only providing a Haskell API with more -- conventional types, replacing error codes with exceptions, helping to -- ensure that allocated resources are freed (using the "with" -- functions). All the used types and utility functions are exposed. -- -- A usage example: -- --
--   import Network.LibSSH as SSH
--   import qualified Data.ByteString.Char8 as BS
--   
--   main :: IO ()
--   main = withSSH $
--     withSession [OptHost "example.com", OptPort 22, OptUser (Just "user"),
--                  OptKnownhosts Nothing, OptTimeout 600] $ \session ->
--     withConnection session $ do
--     authenticateWithKeys session Nothing "id_rsa.pub" "id_rsa" Nothing
--     withSessionChannel session $ \channel ->
--       channelRequestExec channel "uname -a"
--       >> channelReadAll channel >>= BS.putStrLn
--     withSFTPSession session $ \sftp -> do
--       sftpRead sftp "/tmp/example.txt" >>= BS.putStrLn
--       sftpUnlink sftp "/tmp/example.txt"
--   
module Network.LibSSH -- | Invokes ssh_init and ssh_finalize. Library usage must be -- wrapped into it for correct functioning if libssh is linked -- statically, or with its versions before 0.8.0. Not necessary, but -- still safe to use otherwise. withSSH :: IO a -> IO a -- | Imports a public key from a file or a PKCS #11 device, performs an -- action with it. withPublicKeyFile :: FilePath -> (SSHKey -> IO a) -> IO a -- | Imports a private key from a file or a PKCS #11 device, performs an -- action with it. withPrivateKeyFile :: FilePath -> Maybe String -> (SSHKey -> IO a) -> IO a data SSHOption OptHost :: String -> SSHOption OptPort :: Int -> SSHOption OptPortStr :: String -> SSHOption OptFd :: Int -> SSHOption OptBindaddr :: String -> SSHOption OptUser :: Maybe String -> SSHOption OptSSHDir :: Maybe FilePath -> SSHOption OptKnownhosts :: Maybe FilePath -> SSHOption OptIdentity :: String -> SSHOption OptTimeout :: Int -> SSHOption OptTimeoutUsec :: Int -> SSHOption setOption :: SSHSession -> SSHOption -> IO () -- | Performs an action with a new session, with options set for it. withSession :: [SSHOption] -> (SSHSession -> IO a) -> IO a -- | Connects, performs an action, disconnects. withConnection :: SSHSession -> IO a -> IO a -- | Authenticates using the provided key pair. authenticateWithKeys :: SSHSession -> Maybe String -> FilePath -> FilePath -> Maybe String -> IO () -- | Authenticates using a password authenticateWithPassword :: SSHSession -> Maybe String -> String -> IO () -- | Authenticates using SSH agent. authenticateWithAgent :: SSHSession -> Maybe String -> IO () -- | Authenticates using the "none" method. authenticateWithNone :: SSHSession -> Maybe String -> IO () -- | Performs an action with a new channel (ssh_channel_new). withChannel :: SSHSession -> (SSHChannel -> IO a) -> IO a -- | Performs an action with a new session channel -- (ssh_channel_open_session). withSessionChannel :: SSHSession -> (SSHChannel -> IO a) -> IO a -- | Executes a shell command with ssh_channel_request_exec. channelRequestExec :: SSHChannel -> String -> IO CInt -- | Reads all data from a channel with ssh_channel_read and -- readAll. channelReadAll :: SSHChannel -> IO ByteString -- | Performs an action with a new SFTP session. withSFTPSession :: SSHSession -> (SFTPSession -> IO a) -> IO a -- | Reads file contents over SFTP. sftpRead :: SFTPSession -> FilePath -> IO ByteString -- | Unlinks (deletes, removes) a remote file. sftpUnlink :: SFTPSession -> FilePath -> IO () data SSHErrorType SSHErrorCode :: Int -> SSHErrorType SSHNull :: SSHErrorType data SSHError SSHError :: String -> SSHErrorType -> SSHError -- | Throws an exception if the number returned by the provided action is -- less than 0. throwOnError :: Integral a => String -> IO a -> IO a -- | Throws an exception if the performed action returns a NULL. throwOnNull :: String -> IO (Ptr a) -> IO (Ptr a) -- | Reads data using a provided action, until the returned number is 0 -- (indicating EOF) or less (indicating an error, leading to an -- exception). readAll :: (Integral a, Integral b) => String -> (CString -> a -> IO b) -> IO ByteString -- | Like withCString, but provides a nullPtr on -- Nothing. withCStringMaybe :: Maybe String -> (CString -> IO a) -> IO a instance GHC.Show.Show Network.LibSSH.SSHErrorType instance GHC.Show.Show Network.LibSSH.SSHError instance GHC.Exception.Type.Exception Network.LibSSH.SSHError