Safe Haskell | None |
---|---|
Language | Haskell2010 |
Control.SSH.Tunnel
- data SshTunnelConfig = SshTunnelConfig {}
- openSshTunnel :: MonadManaged m => SshTunnelConfig -> ManagerSettings -> m ManagerSettings
- addFingerprints :: MonadIO m => SshTunnelConfig -> FilePath -> m ()
- data SshTunnel
- makeSshTunnel :: MonadIO m => SshTunnelConfig -> ManagerSettings -> m (ManagerSettings, SshTunnel)
- makeSshTunnelSimple :: MonadIO m => SshTunnelConfig -> m SshTunnel
- closeSshTunnel :: MonadIO m => SshTunnel -> m ()
- saveSshTunnel :: MonadIO m => FilePath -> SshTunnel -> m ()
- loadSshTunnel :: MonadIO m => FilePath -> m SshTunnel
Documentation
data SshTunnelConfig Source #
Configuration of SSH tunnel
Constructors
SshTunnelConfig | |
Fields
|
Instances
Arguments
:: MonadManaged m | |
=> SshTunnelConfig | Configuration of connection |
-> ManagerSettings | Your manager settings that would be extended with proxy information |
-> m ManagerSettings | Extended client manager settings, tunnel termination action is handled by |
Open SSH tunnel and return settings for connection manager
Tunnel is created with:
ssh -f -N -M -S master-socket -i pemfile -L localport:127.0.0.1:remoteport user
host
@
Note: that the tunnel is created in background (-f) without a shell on remote host (-N) and (-M -S master-socket) defines special socket that is used to terminate the tunnel.
How to use in your code: @ import Control.Monad.Managed import Control.SSH.Tunnel import Network.HTTP.Client import Network.HTTP.Client.TLS
with (openSshTunnel config tlsManagerSettings) $ settings -> do manager <- newManager settings -- do things with manager -- as soon you live the scope, tunnel will be down @
addFingerprints :: MonadIO m => SshTunnelConfig -> FilePath -> m () Source #
Add server fingerprints to given path
Arguments
:: MonadIO m | |
=> SshTunnelConfig | Configuration of connection |
-> ManagerSettings | Your manager settings that would be extended with proxy information |
-> m (ManagerSettings, SshTunnel) | Extended client manager settings and id that can be used to shut down the tunnel |
Make a SSH tunnel, same as openSshTunnel
, but handles all Managed
monad
stuff internally. As soon as SshTunnel
value is garbage collected, internal
ssh tunnel will be closed. Also you can use closeSshTunnel
to manually free
resources.
makeSshTunnelSimple :: MonadIO m => SshTunnelConfig -> m SshTunnel Source #
Helper, when you don't need manager in makeSshTunnelSimple
closeSshTunnel :: MonadIO m => SshTunnel -> m () Source #
Closes given ssh tunnel, see makeSshTunnel
saveSshTunnel :: MonadIO m => FilePath -> SshTunnel -> m () Source #
Write down info about tunnel into file to be able to close it from other haskell program.
loadSshTunnel :: MonadIO m => FilePath -> m SshTunnel Source #
Read saved tunnel from file that was written by saveSshTunnel