Open
Description
Hello,
I am running into the case where getHostKey
always returns an empty string. This happens on two very distinct SFTP servers, one of which is an AWS Transfer Family SFTP server; the other is an old mainframe-like SFTP server.
In both cases, the host key type returned is 1
, which I assume to be TYPE_PLAIN
as per
Below is the code I use to initialise my SFTP session:
withSftpUser :: forall m a
. MonadLog m
=> MonadMetrics m
=> MonadThrow m
=> MonadUnliftIO m
=> SftpConfigF Text
-> (Sftp -> m a)
-> m a
withSftpUser config action = withSession (host config) (port config) $ \session -> do
checkHost session (host config) (port config) (knownHosts config) >>= \case
MISMATCH -> logError "Host key mismatch" >> throwM ERROR_KNOWN_HOSTS
FAILURE -> logError "Failed to verify host key" >> throwM ERROR_KNOWN_HOSTS
NOTFOUND -> logError "Host key not found" >> throwM ERROR_KNOWN_HOSTS
MATCH -> logInfo "Verified host key"
case credentials config of
MkUserPass (UserPass (Username username) password) ->
liftIO $ usernamePasswordAuth session (Text.unpack username) (Text.unpack password)
withSftpSession session action
withSftpSession :: forall m a
. MonadUnliftIO m
=> Session
-> (Sftp -> m a)
-> m a
withSftpSession session = bracket (liftIO $ sftpInit session) (liftIO . sftpShutdown)
withSession :: forall m a
. MonadUnliftIO m
=> Text
-> Int
-> (Session -> m a)
-> m a
withSession hostname port = bracket
(liftIO $ initialize True >> sessionInit (Text.unpack hostname) port)
(liftIO . sessionClose)
As far as I can see, the FFI in libssh2-hs for getHostKey
is correct. Am I missing something?
Metadata
Assignees
Labels
No labels
Activity