-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | FFI bindings to libssh2 SSH2 client library (http://libssh2.org/) -- -- This package provides FFI bindings for SSH2 client library named -- libssh2. -- -- As of version 0.2 all blocking is handled in Haskell code rather than -- in C code. This means that all calls are now interruptable using -- Haskell asynchronous exceptions; for instance, it is now possible to -- use System.Timeout in combination with libssh2. -- -- Note on usage on Windows: On Windows you MUST compile your -- executable with -threaded or libssh2 will NOT work. We -- have tested libssh2 on Windows using http://mingw.org/, -- with http://www.openssl.org/ and http://libssh2.org/ -- compiled from source (be sure to pass the shared option to the -- configure script for openssl to enable the shared libraries). @package libssh2 @version 0.2.0.1 -- | Block until a read or write operation on a socket would succeed -- -- On most platforms this uses threadWaitRead or -- threadWaitWrite, but on Windows we need to do something -- different. -- -- See http://hackage.haskell.org/trac/ghc/ticket/5797. module Network.SSH.Client.LibSSH2.WaitSocket threadWaitRead :: Socket -> IO () threadWaitWrite :: Socket -> IO () module Network.SSH.Client.LibSSH2.Types data Session data KnownHosts data Channel class ToPointer p toPointer :: ToPointer p => p -> Ptr () -- | Session directions data Direction INBOUND :: Direction OUTBOUND :: Direction int2dir :: (Eq a, Num a, Show a) => a -> [Direction] type CStringCLen i = (CString, i) type Size = CUInt type SSize = CInt withCStringLenIntConv :: Integral i => String -> (CStringCLen i -> IO a) -> IO a peekCStringPtr :: Ptr CString -> IO String peekMaybeCStringPtr :: Ptr CString -> IO (Maybe String) channelFromPointer :: Session -> Ptr () -> IO Channel knownHostsFromPointer :: Ptr () -> IO KnownHosts sessionFromPointer :: Ptr () -> IO Session sessionGetSocket :: Session -> IO (Maybe Socket) sessionSetSocket :: Session -> Maybe Socket -> IO () channelSession :: Channel -> Session instance Typeable Channel instance Data Channel instance Eq Channel instance Typeable KnownHosts instance Data KnownHosts instance Eq KnownHosts instance Typeable Session instance Data Session instance Eq Session instance Eq Direction instance Show Direction instance ToPointer Channel instance Show Channel instance ToPointer KnownHosts instance Show KnownHosts instance ToPointer Session instance Show Session module Network.SSH.Client.LibSSH2.Errors -- | Error codes returned by libssh2. data ErrorCode NONE :: ErrorCode SOCKET_NONE :: ErrorCode BANNER_RECV :: ErrorCode BANNER_SEND :: ErrorCode INVALID_MAC :: ErrorCode KEX_FALIURE :: ErrorCode ALLOC :: ErrorCode SOCKET_SEND :: ErrorCode KEY_EXCHANGE_FAILURE :: ErrorCode TIMEOUT :: ErrorCode HOSTKEY_INIT :: ErrorCode HOSTKEY_SIGN :: ErrorCode DECRYPT :: ErrorCode SOCKET_DISCONNECT :: ErrorCode PROTO :: ErrorCode PASSWORD_EXPIRED :: ErrorCode FILE :: ErrorCode METHOD_NONE :: ErrorCode AUTHENTICATION_FAILED :: ErrorCode PUBLICKEY_UNVERIFIED :: ErrorCode CHANNEL_OUTOFORDER :: ErrorCode CHANNEL_FAILURE :: ErrorCode CHANNEL_REQUEST_DENIED :: ErrorCode CHANNEL_UNKNOWN :: ErrorCode CHANNEL_WINDOW_EXCEEDED :: ErrorCode CHANNEL_PACKET_EXCEEDED :: ErrorCode CHANNEL_CLOSED :: ErrorCode CHANNEL_EOF_SENT :: ErrorCode SCP_PROTOCOL :: ErrorCode ZLIB :: ErrorCode SOCKET_TIMEOUT :: ErrorCode SFTP_PROTOCOL :: ErrorCode REQUEST_DENIED :: ErrorCode METHOD_NOT_SUPPORTED :: ErrorCode INVAL :: ErrorCode INVALID_POLL_TYPE :: ErrorCode PUBLICKEY_PROTOCOL :: ErrorCode EAGAIN :: ErrorCode BUFFER_TOO_SMALL :: ErrorCode BAD_USE :: ErrorCode COMPRESS :: ErrorCode OUT_OF_BOUNDARY :: ErrorCode AGENT_PROTOCOL :: ErrorCode SOCKET_RECV :: ErrorCode ENCRYPT :: ErrorCode BAD_SOCKET :: ErrorCode -- | Exception to throw when null pointer received from libssh2. data NULL_POINTER class IntResult a intResult :: IntResult a => a -> Int -- | Get last error information. getLastError :: Session -> IO (Int, String) -- | Throw an exception if negative value passed, or return unchanged -- value. handleInt :: IntResult a => Maybe Session -> IO a -> IO a handleBool :: CInt -> IO Bool -- | Throw an exception if null pointer passed, or return it casted to -- right type. handleNullPtr :: Maybe Session -> (Ptr () -> IO a) -> IO (Ptr ()) -> IO a int2error :: Integral i => i -> ErrorCode error2int :: Num i => ErrorCode -> i -- | Get currently blocked directions blockedDirections :: Session -> IO ([Direction]) threadWaitSession :: Maybe Session -> IO () instance Typeable ErrorCode instance Typeable NULL_POINTER instance Eq ErrorCode instance Show ErrorCode instance Ord ErrorCode instance Enum ErrorCode instance Data ErrorCode instance Eq NULL_POINTER instance Show NULL_POINTER instance Data NULL_POINTER instance IntResult CLong instance IntResult CInt instance IntResult (Int, a, b, c) instance IntResult (Int, a, b) instance IntResult (Int, a) instance IntResult Int instance Exception NULL_POINTER instance Exception ErrorCode module Network.SSH.Client.LibSSH2.Foreign data KnownHosts data KnownHostResult MATCH :: KnownHostResult MISMATCH :: KnownHostResult NOTFOUND :: KnownHostResult FAILURE :: KnownHostResult data KnownHostType TYPE_MASK :: KnownHostType TYPE_PLAIN :: KnownHostType TYPE_SHA1 :: KnownHostType TYPE_CUSTOM :: KnownHostType KEYENC_MASK :: KnownHostType KEYENC_RAW :: KnownHostType KEYENC_BASE64 :: KnownHostType KEY_MASK :: KnownHostType KEY_SHIFT :: KnownHostType KEY_RSA1 :: KnownHostType KEY_SSHRSA :: KnownHostType KEY_SSHDSS :: KnownHostType data KnownHost KnownHost :: CUInt -> Ptr () -> String -> String -> [KnownHostType] -> KnownHost khMagic :: KnownHost -> CUInt khNode :: KnownHost -> Ptr () khName :: KnownHost -> String khKey :: KnownHost -> String khTypeMask :: KnownHost -> [KnownHostType] -- | Initialize libssh2. Pass True to enable encryption or False to disable -- it. initialize :: Bool -> IO () -- | Deinitialize libssh2. exit :: IO () -- | Create Session object initSession :: IO Session -- | Free Session object's memory freeSession :: Session -> IO () -- | Disconnect session (but do not free memory) disconnectSession :: Session -> String -> IO () -- | Run SSH handshake on network socket. handshake :: Session -> Socket -> IO () setBlocking :: Session -> Bool -> IO () -- | Create KnownHosts object for given session. initKnownHosts :: Session -> IO KnownHosts -- | Free KnownHosts object's memory freeKnownHosts :: KnownHosts -> IO () -- | Read known hosts from file knownHostsReadFile :: KnownHosts -> FilePath -> IO Int -- | Get remote host public key getHostKey :: Session -> IO (String, Size, CInt) -- | Check host data against known hosts. checkKnownHost :: KnownHosts -> String -> Int -> String -> [KnownHostType] -> IO KnownHostResult -- | Perform public key authentication. publicKeyAuthFile :: Session -> String -> String -> String -> String -> IO () -- | Open a channel for session. openChannelSession :: Session -> IO Channel -- | Close channel (but do not free memory) closeChannel :: Channel -> IO () -- | Free channel object's memory freeChannel :: Channel -> IO () channelSendEOF :: Channel -> IO () channelWaitEOF :: Channel -> IO () channelIsEOF :: Channel -> IO (Bool) -- | Read data from channel. readChannel :: Channel -> Size -> IO ByteString -- | Write data to channel. writeChannel :: Channel -> ByteString -> IO () -- | Write all data to channel from handle. Returns amount of transferred -- data. writeChannelFromHandle :: Channel -> Handle -> IO Integer -- | Read all data from channel to handle. Returns amount of transferred -- data. readChannelToHandle :: Channel -> Handle -> Offset -> IO Integer channelProcess :: Channel -> String -> String -> IO () -- | Execute command channelExecute :: Channel -> String -> IO () -- | Execute shell command channelShell :: Channel -> IO () requestPTY :: Channel -> String -> IO () requestPTYEx :: Channel -> String -> String -> Int -> Int -> Int -> Int -> IO (Int) -- | Get channel exit status channelExitStatus :: Channel -> IO (Int) -- | Get channel exit signal. Returns: (possibly error code, exit signal -- name, possibly error message, possibly language code). channelExitSignal :: Channel -> IO (Int, String, Maybe String, Maybe String) -- | Create SCP file send channel. scpSendChannel :: Session -> String -> Int -> Int64 -> POSIXTime -> POSIXTime -> IO Channel -- | Create SCP file receive channel. TODO: receive struct stat also. scpReceiveChannel :: Session -> FilePath -> IO (Channel, Offset) data TraceFlag T_TRANS :: TraceFlag T_KEX :: TraceFlag T_AUTH :: TraceFlag T_CONN :: TraceFlag T_SCP :: TraceFlag T_SFTP :: TraceFlag T_ERROR :: TraceFlag T_PUBLICKEY :: TraceFlag T_SOCKET :: TraceFlag setTraceMode :: Session -> [TraceFlag] -> IO () instance Eq KnownHostType instance Show KnownHostType instance Eq KnownHostResult instance Show KnownHostResult instance Ord KnownHostResult instance Enum KnownHostResult instance Eq KnownHost instance Show KnownHost instance Eq TraceFlag instance Show TraceFlag module Network.SSH.Client.LibSSH2 data Session data Channel data KnownHosts -- | Execute some actions within SSH2 connection. Uses public key -- authentication. withSSH2 :: FilePath -> FilePath -> FilePath -> String -> String -> String -> Int -> (Session -> IO a) -> IO a -- | Execute some actions within SSH2 session withSession :: String -> Int -> (Session -> IO a) -> IO a -- | Execute some actions withing SSH2 channel withChannel :: Session -> (Channel -> IO a) -> IO (Int, a) -- | Generalization of withChannel withChannelBy :: IO a -> (a -> Channel) -> (a -> IO b) -> IO (Int, b) checkHost :: Session -> String -> Int -> FilePath -> IO KnownHostResult -- | Read all data from the channel -- -- Although this function returns a lazy bytestring, the data is -- not read lazily. readAllChannel :: Channel -> IO ByteString -- | Write a lazy bytestring to the channel writeAllChannel :: Channel -> ByteString -> IO () -- | Send a file to remote host via SCP. Returns size of sent data. scpSendFile :: Session -> Int -> FilePath -> FilePath -> IO Integer -- | Receive file from remote host via SCP. Returns size of received data. scpReceiveFile :: Session -> FilePath -> FilePath -> IO Integer runShellCommands :: Session -> [String] -> IO (Int, [ByteString]) execCommands :: Session -> [String] -> IO (Int, [ByteString]) -- | Similar to Network.connectTo, but does not socketToHandle. socketConnect :: String -> Int -> IO Socket