strongbox-password-safe / Strongbox

A KeePass/Password Safe Client for iOS and OS X
https://strongboxsafe.com
GNU Affero General Public License v3.0
1.34k stars 102 forks source link

Sftp cannot Connect #266

Closed NotClear closed 4 years ago

NotClear commented 4 years ago

I have configured my Raspberry pi so that it can be accessed via Sftp, which also works with other apps. Here, however, do I get the same error message every time?! 348C09FD-DA5E-4452-81C3-47ABCA34CDCD

mmcguill commented 4 years ago

Hi, do you know what authentication modes are enabled on your server?

NotClear commented 4 years ago

I had an rsa key created via Keygen or what is the question?

mmcguill commented 4 years ago

I was asking what SSH login modes are supported by your server (e.g. keyboard-interactive, username/password, publickey).

Looks like you're using publickey which is fine... Authentication is failing however. You should be able to find out more detail by looking in your server logs.

The only thing that I think could be wrong is that your are not sending the right Private Key (note Private Key)... Or that you are either not providing the right password or providing a password when none is required.

NotClear commented 4 years ago

It is not because of the privatekey, since it also works in several other programs. My question is whether the password has to be given or whether the privatekey file is enough

mmcguill commented 4 years ago

It will totally depend on how you've configured your Private Key. Is it encoded by a password or not?

To be very clear: The password here means the password for your private key, not a logon password for your SFTP server, or the Master Password for your database.

I assume you used ssh-keygen? if you open your key file in an editor does it being something like:

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

?

NotClear commented 4 years ago

I followed this tutorial https://youtu.be/xt9T6HCAfJY

mmcguill commented 4 years ago

I'm afraid I don't speak German, but a quick scan of that video it looks like no password is used to protect the id_rsa private key file, which is fine. There is something later in the video about using Putty which uses a different format for private keys. You should not use this format.

So you should be selecting the file "id_rsa" (if you used the same setup as in the video) as your private key file with no password. Is that what you are doing?

NotClear commented 4 years ago

Yes

mmcguill commented 4 years ago

Can you tell me what other programs you are using to connect successfully?

And if possible can you paste the configuration (screenshot with confidential items blanked out will do).

NotClear commented 4 years ago

the app i use is called ftpmanager E225FA56-643B-4E99-869F-50512720F8F3

mmcguill commented 4 years ago

That dialog appears to show you are using a PPK file for the private key with that program.

Can you now paste a screenshot of the dialog in Strongbox as you try to connect?

georgesnow commented 4 years ago

are you including the port in the sftp hostname?

mmcguill commented 4 years ago

That was my next question...

NotClear commented 4 years ago

Here 42852F7D-6E3E-4D16-90BD-EFFBE492FDDC

georgesnow commented 4 years ago

so I just tried this myself using a password. I couldn't connect either. I got the same error.

mmcguill commented 4 years ago

He's not using a password though @georgesnow - if you supply a password with a none passworded private key file - it will fail like this as it should.

@NotClear You definitely didn't set a password when creating the key via ssh-keygen?

georgesnow commented 4 years ago

understood, I was attempting to just baseline SFTP connection then try a private key, and finally private key with password.

NotClear commented 4 years ago

Yes the privatekey is Without a password

mmcguill commented 4 years ago

I'm afraid I'm very much out of ideas. Do your SSHD logs show any sign of what could be wrong?

georgesnow commented 4 years ago

I got it to work with a password, but I had to leave the path as the root: / I can test later using public/private key pair

georgesnow commented 4 years ago

ok it fails for me with public key no password. I generated a fresh key installed it on the host sftp server. specified the private key on strongbox and failed. tried again just using a password and I can connect successfully.

georgesnow commented 4 years ago

one other tidbit and strange thing. using command line to ssh works. so there is something about the framework/implenentation that isn't working correctly.

mmcguill commented 4 years ago

Hi @georgesnow, I'm currently able to connect to my own SFTP server using a private key and no password...

Can you specify a list of commands here to generate the key, how you added it to your server and the command line you used then to connect to that server?

Happy to take a look if I can get the steps to reproduce the issue.

georgesnow commented 4 years ago
touch strongbox_rsa
ssh-keygen
less strongbox_rsa _(<=copy the key)_
nano authorized_keys _(paste key)_
ssh -I strongbox_rsa host _(separate machine to test that is a lower case i but it keeps correcting it)_
mmcguill commented 4 years ago

@georgesnow - I'm not an SSH expert, but aren't you supposed to paste the public key (strongbox_rsa.pub) into authorized_keys?

georgesnow commented 4 years ago

that's the nano part. nano is like vi or vim. you just add another line below with the key you copied from keygen

ssh-rsa -yourkey- me@whatever.blah

georgesnow commented 4 years ago

but the end result is the same. I tested the key from another machine and it works.

mmcguill commented 4 years ago

Understood but you seem to have copied from the private key: (less strongbox_rsa, rather than less strongbox_rsa.pub)

georgesnow commented 4 years ago

that's a typo in the post. I went back and confirmed (and re-test form separate host machine specifying that private key). with a public key installed on the first machine.

I had copied and pasted, but sanitized the output and I must have cut off or pasted the wrong line.

georgesnow commented 4 years ago

curious what happens to the permissions of the private key file when copied into strongbox? how does it maintain the proper permissions?

mmcguill commented 4 years ago

I'm afraid I can't spend any more time on this one for a while, higher priorities. But would be great to see if you can get it working, and if so to paste the exact steps in here.

Regarding permissions, it's just a data blob read from a URL using standard iOS APIs... no permissions needed or considered. This data blob is handed down to libssh to connect.

This is the first report of an issue here, I know there are plenty of people connecting to SFTP servers via public-key auth, so I'm going to wait for other reports. I'm also able to connect to my own server with one.

georgesnow commented 4 years ago

sounds good. I don't use SFTP for this purpose (ie strongbox). I sue ssh/sftp for other things regularly. I really just wanted to see if going through the basic motions I could get it to work on the first try. I will tinker some more. if I figure it out and have time I will post back here.

mmcguill commented 4 years ago

Thanks @georgesnow

@NotClear - Wishing you luck getting this working, I'm out of ideas for what could be wrong. Please let us know if you manage to get this working. Hopefully I'll get time to investigate further soon...

georgesnow commented 4 years ago

well, I couldn't get it to work, with strongbox (or another iOS SSH app). However, the key works no problem between Macs. 🤷‍♂️ I am generating OpenSSH keys.

Is there some other type that's required?

on the other iOS app (WebSSH). I get "SSH key object did not contain a load private key" when trying SFTP. This app requires you to paste the private key string into it. SSH says bad credentials. That doesn't make sense since I know the key works from another device.

@mmcguill do you have specifics how you created your key and what device? Also how you added the public key to your known hosts? etc..

mmcguill commented 4 years ago

Hi @georgesnow - I don't have specifics, it was quite a while ago, however the start of my working private key begins like this:

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

but the newer keys that I generate begin:

-----BEGIN OPENSSH PRIVATE KEY-----

I'm quite suspicious though that we're not doing something right here in setup.

georgesnow commented 4 years ago

I am starting to think the same. Need to find a known good workflow. Well, not sure I will have any time to further troubleshoot right now. If I get a chance and figure it out I will post back.

janprzy commented 4 years ago

Same issue here. I'm using a password-protected ed25519 key (also tried RSA, didn't work either). The same key works fine when logging in via Terminal my Mac. Also, password authentication is disabled on my server. The server logs are not very helpful, they just say "failed unknown".

I also tried multiple other apps: It works fine in Termius and PhotoSync, while both Documents and Pisth fail as well. Maybe the problem originates from some library that Strongbox and these two apps use.

mmcguill commented 4 years ago

OK, definitely seems like there's an issue here. I'll rebuild the ssl/ssh libraries with latest source and see if that will fix things...

mmcguill commented 4 years ago

1.45.16 is now available from the App Store with updated SSH libraries. Appreciate any feedback you guys have with that version.

janprzy commented 4 years ago

It works now, thank you!

mmcguill commented 4 years ago

That's great to hear. @georgesnow - can you confirm on your end?

georgesnow commented 4 years ago

I will do that. Probably won’t get a chance until tomorrow

mmcguill commented 4 years ago

@NotClear - Could you give the latest version a try and see if it fixes things for you?

NotClear commented 4 years ago

@mmcguill Yes I updated the app and now everything works flawlessly thank you.