-
Notifications
You must be signed in to change notification settings - Fork 340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SFTP encrypted private key #158
Comments
Unfortunately this is not supported by go yet: golang/go#18692 |
The current workaround seems to be to use an SSH agent instead (which should define SSH_AUTH_SOCK in the environment) |
Chiming in on this issue as it's exactly what I'm having problems with. Duplicacy doesn't make use of the ssh-agent I have loaded with the key for the server. Instead it keeps asking me for the path to the private key, which it does when I don't use the ssh-agent as well.
Any idea why it's still asking me for the path to the key, instead of using the ssh-agent, which is what the documentation says it does? |
Add -background to the command line to suppress the prompt. |
No dice:
I have disabled SSH's use of the keychain in my macOS 10.12 by adding |
@gilbertchen FWIW, restic handles this fine - if there's an SSH agent loaded it uses that, and if there isn't it asks for the password of the SSH key. I'm not trying to promote restic here, but I know this particular thing works there, so perhaps it might be worth taking a look at how it's done there. The PR for it is here: restic/restic#1270 |
Do you have the environment variable SSH_AUTH_SOCK set up and pointed to your ssh agent? |
@gilbertchen Yes, I do. And I tested it with restic, which doesn't ask for the private key password but instead goes directly to ask me for the repository password. Had it not used the ssh-agent for the key, it would either have asked me for the SSH key passphrase or not worked at all. So the ssh-agent does work, AFAICT. EDIT: I have the agent running in two separate terminal sessions. In the first one I have |
Can you run |
Sure, here's the output of that:
|
This log message means the following lines were called: duplicacy/src/duplicacy_storage.go Lines 237 to 242 in b2ad6da
Since it didn't report an error, I guess for some reason It looks like restic runs an external ssh process to obtain the sftp channel so it works differently. |
Yes,
The key was added using |
Can you create a new ssh agent by running Also running the remote sshd with the |
What I did was:
I then ran Let's take a step back and look at the code in duplicacy_storage.go. Considering that I'm not seeing the message in line 241 ("Can't log in using public key authentication via agent"), it seems like the agent support has been loaded fine. But then I see the message in line 246 ("Enter the path of the private key file"), and that seems odd. If the agent loaded fine, it should be managing the key, so why would Duplicacy then ask me for the path to the private key file? It seems wrong that it does (that and perhaps the code following that as well). |
What is the output from duplicacy/src/duplicacy_storage.go Lines 232 to 246 in b0a67ce
Here on line 239 it tries to retrieve the signers from the agent and authentication doesn't happen yet. It may not get any signer or the signers may not work at all therefore it may need to create a new signer from the private key file. The logic seems a bit awkward, but this is mainly due to the poor api design of the go's ssh library in my opinion. |
Here's the output from the ssh-agent, should have included this in my previous post of course:
Okay, but can't you ask for the private key path only if the signers from the agent doesn't work? I dunno, just seemed wrong that it ALWAYS asks for the private key path, since if the agent works this shouldn't be needed I guess. |
This is the output of
Compared with your output, you were missing |
Here is hopefully the mother of all debug outputs, including the ssh-agent, the client, and the server, both for when I do supply the path to the private key when asked, and when I don't. It looks like there's a missing username in there when the client connects, but perhaps that's just normal when pubkey is supposed to be used. To be clear, between each of these, I restarted the ssh-agent, the sshd and completely restarted the client shell as well. So it should all be pristine for each run.
|
I think it is the missing username that caused the problem. The storage url should be |
Doesn't seem to help. Are you interested in debug output from when i SUPPLY the key path, or when I don't? |
I'm pretty sure it is the username. At least not providing one is wrong. A debug output with a fake key path should be enough. |
Yes, you are right. Adding the username to the URL made it work. However, IMO one should not have to supply the username in the URL. If there's no username in the URL, the current username of the shell should be used, just as is usual in most other common cases (e.g. if I sftp to a server using |
Would of course also be nice to not have to supply the darn key path. Shouldn't be needed. |
On Windows, trying to use a private key encrypted with a password, Duplicacy does not ask for the
password:
Is there a way to set the private key password?
Thanks.
The text was updated successfully, but these errors were encountered: