SFTP

buon pomeriggio, devo sviluppare un applicazione che si connette ad un server SFTP e scarica un file, chi gestisce il server remoto mi ha fornito i seguenti parametri:

username,host,port

e mi chiede di generare (e comunicare loro) una chiave pubblica.

E’ la prima volta che uso un SFTP e vorrei utilizzare il plugin CURLMBS che ho licenziato. Non ho per idea su come avverr l’autenticazione.
Qualcuno pu darmi una dritta?

grazie

Per favore prova qualcosa come questo:

[code]Dim d As New CURLSMBS

d.OptionURL = “sftp://domain/folder/file.txt”
d.OptionUsername = “yyy”
d.OptionPassword = “xxx”

// run download
dim e as integer = d.Perform

// check result
Dim Data As String = d.OutputData
Dim DebugMessage As String = d.DebugData // check in debugger on error[/code]

Qui spiegato come fare.

https://support.google.com/youtube/answer/3071034?hl=it

[quote=426123:@Christian Schmitz]Per favore prova qualcosa come questo:

[code]Dim d As New CURLSMBS

d.OptionURL = “sftp://domain/folder/file.txt”
d.OptionUsername = “yyy”
d.OptionPassword = “xxx”

// run download
dim e as integer = d.Perform

// check result
Dim Data As String = d.OutputData
Dim DebugMessage As String = d.DebugData // check in debugger on error[/code][/quote]

Hi Christian, I’ve found your example but I don’t have a password for the login, I need to generate a public key

Than use property OptionSSHPublicKeyfile and similar.

ok, ho creato con putty le due chiavi come consigliato da massimo

adesso ho due file, la chiave pubblica l’ho comunicata a chi mi espone il server Sftp e quella privata l’ho messa nella configurazione di Filezilla.
Usando FZ Client funziona perfettamente, in Xojo, come imposto la chiave privata nella chiamata Curl?

PS la chiave privata un file id-rsa.ppk, devo copiarne il contenuto in qualche variabile???

grazie

Christian, ho modificato il tuo esempio CURLS Sftp directory listing ma ricevo questo errore:

Rebuilt URL to: sftp://filetransfer.plugandpay.it:22/
  Trying 77.43.5.170...
Connected to filetransfer.plugandpay.it (77.43.5.170) port 22 (#0)
SSH MD5 fingerprint: 9d813bffa6748adaa07a474a45941cb8
SSH authentication methods available: password,publickey,keyboard-interactive
Using SSH public key file 'C:\\Users\\c.marciano.NCS\\.ssh\\id_rsa'
Using SSH private key file 'C:\\Users\\c.marciano.NCS\\.ssh\\id_rsa.ppk'
SSH public key authentication failed: Invalid key data, not base64 encoded
Failure connecting to agent
Authentication failure
Closing connection 0

le chiavi sono state generate con puttygen.exe

dove sta il problema?

Did you set right path for the public key options?

OptionSSHPrivateKeyfile and OptionSSHPublicKeyfile?

yes, I think the problem is here:

SSH public key authentication failed: Invalid key data, not base64 encoded

sample code:

[code]Dim c As New CURLSMBS

c.OptionSSHPrivateKeyfile = “/Users/test/.ssh/id_rsa”
c.OptionSSHPublicKeyfile = “/Users/test/.ssh/id_rsa.pub”
c.OptionUsername = “test”[/code]

If you need public key authentication, please provide correct native paths to the files to use.

I’m sure my paths are correct, tried your example but I get:

Rebuilt URL to: sftp://filetransfer.plugandpay.it:22/
  Trying 77.43.5.170...
Connected to filetransfer.plugandpay.it (77.43.5.170) port 22 (#0)
SSH MD5 fingerprint: 9d813bffa6748adaa07a474a45941cb8
SSH authentication methods available: password,publickey,keyboard-interactive
Using SSH public key file 'C:\\Users\\c.marciano.NCS\\.ssh\\id_rsa.pub'
Using SSH private key file 'C:\\Users\\c.marciano.NCS\\.ssh\\id_rsa'
SSH public key authentication failed: Username/PublicKey combination invalid
Failure connecting to agent
Authentication failure
Closing connection 0

so the correct paths are:
Using SSH public key file ‘C:\Users\c.marciano.NCS\.ssh\id_rsa’
Using SSH private key file ‘C:\Users\c.marciano.NCS\.ssh\id_rsa.ppk’

I see that puttygen.exe set 2048 as number of bits in a generated key

“Username/PublicKey combination invalid”.

You did specify the user name?
you are sure it’s correct?

What does log from other app shows?

Alternatively you could use username/password instead of public keys.

[quote=426986:@Christian Schmitz]“Username/PublicKey combination invalid”.

You did specify the user name?
you are sure it’s correct?

What does log from other app shows?

Alternatively you could use username/password instead of public keys.[/quote]

Hi Christian!

using your suggested paths I get that error, using mine the problem is:

SSH public key authentication failed: Invalid key data, not base64 encoded

the difference beetween your paths and mine is here
YOURS
Using SSH public key file ‘C:\Users\c.marciano.NCS\.ssh\id_rsa.pub
Using SSH private key file ‘C:\Users\c.marciano.NCS\.ssh\id_rsa
MINE
Using SSH public key file ‘C:\Users\c.marciano.NCS\.ssh\id_rsa
Using SSH private key file ‘C:\Users\c.marciano.NCS\.ssh\id_rsa.ppk

I cannot use username/password authetication…

please note that the same couple of keys (mine) in Filezilla works

“Invalid key data, not base64 encoded”.

What key data do you have?
Maybe you have DER (binary) format and need to convert to PEM format?

[quote=427193:@Christian Schmitz]“Invalid key data, not base64 encoded”.

What key data do you have?
Maybe you have DER (binary) format and need to convert to PEM format?[/quote]
I’ve used puttygen with standard options to generate the keys following this:

https://support.google.com/youtube/answer/3071034?hl=it

[quote=427193:@Christian Schmitz]“Invalid key data, not base64 encoded”.

What key data do you have?
Maybe you have DER (binary) format and need to convert to PEM format?[/quote]

Christian, here You can see how I made the keys…

https://www.dropbox.com/s/didmczvwagkjp7d/Cattura.PNG?dl=0

Well, the key file must be there at the given path. It must be in right format.

The key file could start with text

-----BEGIN RSA PRIVATE KEY-----

For my login I just used one key file, not two.

[quote=427214:@Christian Schmitz]Well, the key file must be there at the given path. It must be in right format.

The key file could start with text

-----BEGIN RSA PRIVATE KEY-----

For my login I just used one key file, not two.[/quote]
check now the img

In that dialog, you see a public key above.

But you need to save the private key with the button, I bet.
Put it in a file and tell the plugin to use that file
That may work.

already done, the files are correctly used by your plugin, the problem is in the encoding not base 64?

maybe a property on the plugin to set?