libssh2-0.1: FFI bindings to libssh2 SSH2 client library (http://libssh2.org/)

Safe HaskellNone

Network.SSH.Client.LibSSH2.Foreign

Contents

Synopsis

Types

data Direction Source

Session directions

Constructors

INBOUND 
OUTBOUND 

Session functions

initialize :: Bool -> IO IntSource

Initialize libssh2. Pass True to enable encryption or False to disable it.

exit :: IO ()Source

Deinitialize libssh2.

initSession :: IO SessionSource

Create Session object

freeSession :: Session -> IO IntSource

Free Session object's memory

disconnectSessionSource

Arguments

:: Session 
-> String

Goodbye message

-> IO Int 

Disconnect session (but do not free memory)

handshake :: Session -> Socket -> IO IntSource

Run SSH handshake on network socket.

blockedDirections :: Session -> IO [Direction]Source

Get currently blocked directions

Known hosts functions

initKnownHosts :: Session -> IO KnownHostsSource

Create KnownHosts object for given session.

freeKnownHosts :: KnownHosts -> IO ()Source

Free KnownHosts object's memory

knownHostsReadFileSource

Arguments

:: KnownHosts 
-> FilePath

Path to known_hosts file

-> IO Int 

Read known hosts from file

getHostKey :: Session -> IO (String, Size, CInt)Source

Get remote host public key

checkKnownHostSource

Arguments

:: KnownHosts 
-> String

Host name

-> Int

Port number (usually 22)

-> String

Host public key

-> [KnownHostType]

Host flags (see libssh2 documentation)

-> IO KnownHostResult 

Check host data against known hosts.

Authentication

publicKeyAuthFile :: Session -> String -> String -> String -> String -> IO IntSource

Perform public key authentication. Arguments are: session, username, path to public key file, path to private key file, passphrase.

Channel functions

openChannelSession :: Session -> IO ChannelSource

Open a channel for session.

closeChannel :: Channel -> IO IntSource

Close channel (but do not free memory)

freeChannel :: Channel -> IO IntSource

Free channel object's memory

readChannelSource

Arguments

:: Channel 
-> Size

Amount of data to read

-> IO (SSize, String) 

Read data from channel. Returns amount of given data and data itself. NOTE: returns bytes sequence, i.e. not Unicode.

writeChannel :: Channel -> String -> IO IntSource

Write data to channel. Returns amount of written data.

writeChannelFromHandle :: (Num b, IsPointer p1, IsPointer p) => p1 -> p -> Handle -> IO bSource

Write all data to channel from handle. Returns amount of transferred data. writeChannelFromHandle :: Channel -> Handle -> IO Integer

readChannelToHandle :: Channel -> Handle -> Offset -> IO IntegerSource

Read all data from channel to handle. Returns amount of transferred data.

channelExecute :: Channel -> String -> IO IntSource

Execute command

channelShell :: Channel -> IO IntSource

Execute shell command

channelExitStatus :: Channel -> IO IntSource

Get channel exit status

channelExitSignal :: Channel -> IO (Int, String, Maybe String, Maybe String)Source

Get channel exit signal. Returns: (possibly error code, exit signal name, possibly error message, possibly language code).

scpSendChannel :: Session -> String -> Int -> Int64 -> POSIXTime -> POSIXTime -> IO ChannelSource

Create SCP file send channel.

scpReceiveChannel :: Session -> FilePath -> IO (Channel, Offset)Source

Create SCP file receive channel. TODO: receive struct stat also.

Debug