Skip to content
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

Support for external ssh-agent #17

Closed
vanhtuan0409 opened this issue Sep 30, 2022 · 15 comments
Closed

Support for external ssh-agent #17

vanhtuan0409 opened this issue Sep 30, 2022 · 15 comments
Labels
enhancement New feature or request ssh
Milestone

Comments

@vanhtuan0409
Copy link

Describe the bug

I'm using a ssh agent with ssh key (algo: ssh-ed25519). When trying to pull the repo from Gitnuro, error pop up

To Reproduce
Steps to reproduce the behavior:

  1. Open a local repository (which use ssh-ed25519 ssh key)
  2. Try to pull

Expected behavior

Able to pull the repo

Logs

Authentication completed with failure
org.eclipse.jgit.api.errors.TransportException: git@redacted.git: remote hung up unexpectedly
	at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:224)
	at org.eclipse.jgit.api.PullCommand.call(PullCommand.java:266)
	at app.git.RemoteOperationsManager$pull$2.invokeSuspend(RemoteOperationsManager.kt:32)
	at app.git.RemoteOperationsManager$pull$2.invoke(RemoteOperationsManager.kt)
	at app.git.RemoteOperationsManager$pull$2.invoke(RemoteOperationsManager.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:165)
	at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
	at app.git.RemoteOperationsManager.pull(RemoteOperationsManager.kt:24)
	at app.viewmodels.MenuViewModel$pull$1.invokeSuspend(MenuViewModel.kt:17)
	at app.viewmodels.MenuViewModel$pull$1.invoke(MenuViewModel.kt)
	at app.viewmodels.MenuViewModel$pull$1.invoke(MenuViewModel.kt)
	at app.git.TabState$safeProcessing$1$2.invokeSuspend(TabState.kt:68)
	at app.git.TabState$safeProcessing$1$2.invoke(TabState.kt)
	at app.git.TabState$safeProcessing$1$2.invoke(TabState.kt)
	at app.extensions.StateManagementUtilsKt.delayedStateChange(StateManagementUtils.kt:21)
	at app.git.TabState$safeProcessing$1.invokeSuspend(TabState.kt:62)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
Caused by: org.eclipse.jgit.errors.TransportException: git@github.com:vanhtuan0409/stargazer.git: remote hung up unexpectedly
	at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:313)
	at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:153)
	at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:151)
	at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:103)
	at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1321)
	at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:213)
	... 22 more
Caused by: org.apache.sshd.common.SshException: No more authentication methods available
	at org.apache.sshd.common.future.AbstractSshFuture.verifyResult(AbstractSshFuture.java:127)
	at org.apache.sshd.client.future.DefaultAuthFuture.verify(DefaultAuthFuture.java:39)
	at org.apache.sshd.client.future.DefaultAuthFuture.verify(DefaultAuthFuture.java:32)
	at org.apache.sshd.common.future.VerifiableFuture.verify(VerifiableFuture.java:43)
	at app.credentials.GRemoteSession.exec(GRemoteSession.kt:44)
	at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:296)
	... 27 more
Caused by: org.apache.sshd.common.SshException: No more authentication methods available
	at org.apache.sshd.client.session.ClientUserAuthService.tryNext(ClientUserAuthService.java:380)
	at org.apache.sshd.client.session.ClientUserAuthService.processUserAuth(ClientUserAuthService.java:315)
	at org.apache.sshd.client.session.ClientUserAuthService.process(ClientUserAuthService.java:252)
	at org.apache.sshd.common.session.helpers.CurrentService.process(CurrentService.java:109)
	at org.apache.sshd.common.session.helpers.AbstractSession.doHandleMessage(AbstractSession.java:594)
	at org.apache.sshd.common.session.helpers.AbstractSession.lambda$handleMessage$0(AbstractSession.java:525)
	at org.apache.sshd.common.util.threads.ThreadUtils.runAsInternal(ThreadUtils.java:66)
	at org.apache.sshd.common.session.helpers.AbstractSession.handleMessage(AbstractSession.java:524)
	at org.apache.sshd.common.session.helpers.AbstractSession.decode(AbstractSession.java:1644)
	at org.apache.sshd.common.session.helpers.AbstractSession.messageReceived(AbstractSession.java:485)
	at org.apache.sshd.common.session.helpers.AbstractSessionIoHandler.messageReceived(AbstractSessionIoHandler.java:64)
	at org.apache.sshd.common.io.nio2.Nio2Session.handleReadCycleCompletion(Nio2Session.java:371)
	at org.apache.sshd.common.io.nio2.Nio2Session$1.onCompleted(Nio2Session.java:344)
	at org.apache.sshd.common.io.nio2.Nio2Session$1.onCompleted(Nio2Session.java:339)
	at org.apache.sshd.common.io.nio2.Nio2CompletionHandler.lambda$completed$0(Nio2CompletionHandler.java:38)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
	at org.apache.sshd.common.io.nio2.Nio2CompletionHandler.completed(Nio2CompletionHandler.java:37)
	at java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:129)
	at java.base/sun.nio.ch.Invoker$2.run(Invoker.java:221)
	at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:113)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

Desktop (please complete the following information):

  • OS:
Linux thinkpad 5.19.12-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 28 Sep 2022 13:21:25 +0000 x86_64 GNU/Linux
  • Java version
openjdk 18.0.2 2022-07-19
OpenJDK Runtime Environment (build 18.0.2+0)
OpenJDK 64-Bit Server VM (build 18.0.2+0, mixed mode)
  • Version: 1.0.1
@vanhtuan0409 vanhtuan0409 added the bug Something isn't working label Sep 30, 2022
@JetpackDuba
Copy link
Owner

JetpackDuba commented Sep 30, 2022

It seems that Gitnuro is not able to find your SSH key. Are you using are you using the default path for the SSH keys? /home/user/.ssh/id_ed25519

Edit: Nvm, ignore this comment, I was thinking of something else. I'll get back to you later.

@JetpackDuba
Copy link
Owner

It seems that Gitnuro is not able to find your SSH key. Are you using are you using the default path for the SSH keys? /home/user/.ssh/id_ed25519

Edit: Nvm, ignore this comment, I was thinking of something else. I'll get back to you later.

Actually, I may have been right. Can you share the path of your SSH Key please? It seems that using the non-default path can be problematic.

@vanhtuan0409
Copy link
Author

oh i see. I have the public key stored inside ~/.ssh but the private key is stored within ssh-agent only.
You can only pull the private key out by using ssh-agent

@JetpackDuba
Copy link
Owner

Unfortunately that is not something supported by Apache SSHD, the library used for the SSH authentication. There aren't any other reliable libs that would help to solve the issue and it's completly out of the scope of the project for now to implement myself, as it would require a considerable effort.

If it's an option, I would suggest storing the private key in the default path.

I'll edit the issue to make the title clearer as well as adding it to the FAQ. I'll also leave the open issue to see if there is additional interest or someone wants to offer a solution.

@JetpackDuba JetpackDuba added enhancement New feature or request and removed bug Something isn't working labels Sep 30, 2022
@JetpackDuba JetpackDuba changed the title Unable to use SSH Support for external ssh-agent Sep 30, 2022
@JetpackDuba JetpackDuba added the ssh label Nov 2, 2022
@alensiljak
Copy link

Any reason not use existing git setup and leave most of this functionality to the components that work outside the application?

I'm using git via SSH and the keys are stored in Pageant (on Windows) and handled via KeePassXC. I'd like to keep that setup, if possible. It works with Git CLI and a few other GUI programs that use Git in the background.

@JetpackDuba
Copy link
Owner

It's mostly because working with Git CLI is quite a pain.

The whole SSH situation will probably be solved once this is finished #33

It's already WIP and I hope it fixes all the SSH related issues once for all x)

@dcolazin
Copy link

If it's an option, I would suggest storing the private key in the default path.

I have the private key on the default path, but I still get the following error:

org.eclipse.jgit.api.errors.TransportException: https://github.com/dcolazin/chesslib.git: authentication not supported at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:159) at com.jetpackduba.gitnuro.git.remote_operations.PushBranchUseCase$invoke$2.invokeSuspend(PushBranchUseCase.kt:26) at com.jetpackduba.gitnuro.git.remote_operations.PushBranchUseCase$invoke$2.invoke(PushBranchUseCase.kt) at com.jetpackduba.gitnuro.git.remote_operations.PushBranchUseCase$invoke$2.invoke(PushBranchUseCase.kt) at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89) at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:166) at kotlinx.coroutines.BuildersKt.withContext(Unknown Source) at com.jetpackduba.gitnuro.git.remote_operations.PushBranchUseCase.invoke(PushBranchUseCase.kt:14) at com.jetpackduba.gitnuro.viewmodels.MenuViewModel$push$1.invokeSuspend(MenuViewModel.kt:40) at com.jetpackduba.gitnuro.viewmodels.MenuViewModel$push$1.invoke(MenuViewModel.kt) at com.jetpackduba.gitnuro.viewmodels.MenuViewModel$push$1.invoke(MenuViewModel.kt) at com.jetpackduba.gitnuro.git.TabState$safeProcessing$1$2.invokeSuspend(TabState.kt:73) at com.jetpackduba.gitnuro.git.TabState$safeProcessing$1$2.invoke(TabState.kt) at com.jetpackduba.gitnuro.git.TabState$safeProcessing$1$2.invoke(TabState.kt) at com.jetpackduba.gitnuro.extensions.StateManagementUtilsKt.delayedStateChange(StateManagementUtils.kt:21) at com.jetpackduba.gitnuro.git.TabState$safeProcessing$1.invokeSuspend(TabState.kt:67) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42) at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:749) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) Caused by: org.eclipse.jgit.errors.TransportException: https://github.com/dcolazin/chesslib.git: authentication not supported at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:674) at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:627) at org.eclipse.jgit.transport.TransportHttp.openPush(TransportHttp.java:541) at org.eclipse.jgit.transport.PushProcess.execute(PushProcess.java:138) at org.eclipse.jgit.transport.Transport.push(Transport.java:1473) at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:149) ... 23 more LastError flow: Error(date=1673985150562, exception=org.eclipse.jgit.api.errors.TransportException: https://github.com/dcolazin/chesslib.git: authentication not supported, message=https://github.com/dcolazin/chesslib.git: authentication not supported)

I use Ubuntu 22.04.1, Gitnuro 1.1.1 jar, openjdk 17.0.5. Is it possible to produce a tutorial on how to pull to Github?

@JetpackDuba
Copy link
Owner

How did you create the key @dcolazin ?

@dcolazin
Copy link

I used this guide by github, I tried using both ed25519 and rsa.

@JetpackDuba JetpackDuba added this to the 1.2.0 milestone Apr 18, 2023
@JetpackDuba
Copy link
Owner

With the merge of the LibSSH support, ssh-agent is supported in all 3 OS and will be available in v1.2.0

@dcolazin
Copy link

Thank you! I will try the snapshot.

@dcolazin
Copy link

dcolazin commented Jun 13, 2023

Hi @JetpackDuba , I tried again with the version 1.2.1, generating both ed25519 and rsa keys. When trying to push to a test repo I get the following error

2023-06-13 07:52:29 INFO  slf4j:8 - OS - OS is linux
2023-06-13 07:52:36 INFO  slf4j:8 - ShellManager - runCommandProcess: !/usr/bin/gh auth git-credential get
org.eclipse.jgit.api.errors.TransportException: https://github.com/dcolazin/testgitnuro: authentication not supported
	at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:168)
	at com.jetpackduba.gitnuro.git.remote_operations.PushBranchUseCase$invoke$2.invokeSuspend(PushBranchUseCase.kt:36)
	at com.jetpackduba.gitnuro.git.remote_operations.PushBranchUseCase$invoke$2.invoke(PushBranchUseCase.kt)
	at com.jetpackduba.gitnuro.git.remote_operations.PushBranchUseCase$invoke$2.invoke(PushBranchUseCase.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:169)
	at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
	at com.jetpackduba.gitnuro.git.remote_operations.PushBranchUseCase.invoke(PushBranchUseCase.kt:16)
	at com.jetpackduba.gitnuro.viewmodels.MenuViewModel$push$1.invokeSuspend(MenuViewModel.kt:55)
	at com.jetpackduba.gitnuro.viewmodels.MenuViewModel$push$1.invoke(MenuViewModel.kt)
	at com.jetpackduba.gitnuro.viewmodels.MenuViewModel$push$1.invoke(MenuViewModel.kt)
	at com.jetpackduba.gitnuro.git.TabState$safeProcessing$job$1$2.invokeSuspend(TabState.kt:131)
	at com.jetpackduba.gitnuro.git.TabState$safeProcessing$job$1$2.invoke(TabState.kt)
	at com.jetpackduba.gitnuro.git.TabState$safeProcessing$job$1$2.invoke(TabState.kt)
	at com.jetpackduba.gitnuro.extensions.StateManagementUtilsKt.delayedStateChange(StateManagementUtils.kt:21)
	at com.jetpackduba.gitnuro.git.TabState$safeProcessing$job$1.invokeSuspend(TabState.kt:119)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Caused by: org.eclipse.jgit.errors.TransportException: https://github.com/dcolazin/testgitnuro: authentication not supported
	at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:674)
	at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:627)
	at org.eclipse.jgit.transport.TransportHttp.openPush(TransportHttp.java:541)
	at org.eclipse.jgit.transport.PushProcess.execute(PushProcess.java:138)
	at org.eclipse.jgit.transport.Transport.push(Transport.java:1537)
	at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:158)
	... 23 more
2023-06-13 07:52:36 ERROR slf4j:16 - TabState - https://github.com/dcolazin/testgitnuro: authentication not supported
org.eclipse.jgit.api.errors.TransportException: https://github.com/dcolazin/testgitnuro: authentication not supported
	at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:168)
	at com.jetpackduba.gitnuro.git.remote_operations.PushBranchUseCase$invoke$2.invokeSuspend(PushBranchUseCase.kt:36)
	at com.jetpackduba.gitnuro.git.remote_operations.PushBranchUseCase$invoke$2.invoke(PushBranchUseCase.kt)
	at com.jetpackduba.gitnuro.git.remote_operations.PushBranchUseCase$invoke$2.invoke(PushBranchUseCase.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:169)
	at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
	at com.jetpackduba.gitnuro.git.remote_operations.PushBranchUseCase.invoke(PushBranchUseCase.kt:16)
	at com.jetpackduba.gitnuro.viewmodels.MenuViewModel$push$1.invokeSuspend(MenuViewModel.kt:55)
	at com.jetpackduba.gitnuro.viewmodels.MenuViewModel$push$1.invoke(MenuViewModel.kt)
	at com.jetpackduba.gitnuro.viewmodels.MenuViewModel$push$1.invoke(MenuViewModel.kt)
	at com.jetpackduba.gitnuro.git.TabState$safeProcessing$job$1$2.invokeSuspend(TabState.kt:131)
	at com.jetpackduba.gitnuro.git.TabState$safeProcessing$job$1$2.invoke(TabState.kt)
	at com.jetpackduba.gitnuro.git.TabState$safeProcessing$job$1$2.invoke(TabState.kt)
	at com.jetpackduba.gitnuro.extensions.StateManagementUtilsKt.delayedStateChange(StateManagementUtils.kt:21)
	at com.jetpackduba.gitnuro.git.TabState$safeProcessing$job$1.invokeSuspend(TabState.kt:119)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Caused by: org.eclipse.jgit.errors.TransportException: https://github.com/dcolazin/testgitnuro: authentication not supported
	at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:674)
	at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:627)
	at org.eclipse.jgit.transport.TransportHttp.openPush(TransportHttp.java:541)
	at org.eclipse.jgit.transport.PushProcess.execute(PushProcess.java:138)
	at org.eclipse.jgit.transport.Transport.push(Transport.java:1537)
	at org.eclipse.jgit.api.PushCommand.call(PushCommand.java:158)
	... 23 more

@JetpackDuba
Copy link
Owner

Hello!

You seem to be using HTTP authentication rather than SSH, the error shows the URL.

@dcolazin
Copy link

Thank you for the fast reply. You were right: I initially cloned the repo using https://github.com/dcolazin/testgitnuro instead of git@github.com:dcolazin/testgitnuro.git. Is there a way to change authentication inside Gitnuro?

@JetpackDuba
Copy link
Owner

JetpackDuba commented Jun 14, 2023

No worries!
Changing the remote URL. Hover the remotes section in the side panel and you will see a cogwheel to edit the remotes. Change both URLs, fetch and push with the SSH URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ssh
Projects
None yet
Development

No branches or pull requests

4 participants