SFTPClient usage - how to connect and upload file?

Hello,

Any ideas how I can use SFTPClient to connect to a remote host using IP, Port, username, password, timeout, and passphrase connection parameters?
Upon successful connection, upload a file to the remote host as well.

I have tried doing this without success

Grateful for any assistance in this regard.

Regards,

Jerry

The parameters you listed seem to line up with the ones that SFTPClient.connect expects; can you provide more specifics on how the connection fails?

Hello @al2o3cr,

Below is the response I get:

** (FunctionClauseError) no function clause matching in :ssh.connect/4

The following arguments were given to :ssh.connect/4:

    # 1
    'X.X.X.X'

    # 2
    "XXX"

    # 3
    [
      user_interaction: false,
      silently_accept_hosts: true,
      quiet_mode: true,
      inet: :inet,
      connect_timeout: 5000
    ]

    # 4
    5000

(ssh 4.10) ssh.erl:158: :ssh.connect/4
(ssh 4.10) ssh_sftp.erl:206: :ssh_sftp.start_channel/3
(sftp_client 1.4.6) lib/sftp_client/operations/connect.ex:139: SFTPClient.Operations.Connect.do_connect/1
(sftp_client 1.4.6) lib/sftp_client/operations/connect.ex:53: SFTPClient.Operations.Connect.connect/1

Connection is as below:

SFTPClient.connect(host: host, port: port, user: user, password: pass, connect_timeout: 50000, operation_timeout: 50000)

Grateful for your response.

Kind regards,

Jerry

The documentation for :ssh.connect/4 specifies that the second argument should be a :inet.port_number() - an integer 0..65535. The double-quotes here suggest you are passing a binary instead.

1 Like

Kindly let me check and try again.

Thank you