JetpackDuba / Gitnuro

A FOSS Git multiplatform client for newbies and pros
https://gitnuro.com/
GNU General Public License v3.0
872 stars 44 forks source link

Clone with ssh protocol gives "remote hung up unexpectedly" #130

Closed happenpappen closed 9 months ago

happenpappen commented 1 year ago

Describe the bug Cloning or pushing/pulling a repository with "ssh://.." protocol gives the error message "remote hung up unexpectedly" (see screenshot). As Git Server we use Bitbucket, cloning the repository with the same URL on command line (where git version 2.39.2 (Apple Git-143) is installed) works without problems.

To Reproduce Steps to reproduce the behavior:

  1. Go to 'Actions'
  2. Click on 'Clone new repository'
  3. Fill in the URL an destination directory.
  4. Click on "Clone"
  5. See error

Expected behavior The repository should be cloned or pulled.

Screenshots grafik

Desktop (please complete the following information):

JetpackDuba commented 1 year ago

Hey!

Perhaps it's the same issue as this? https://github.com/JetpackDuba/Gitnuro/issues/87#issuecomment-1595759722

If you could attach the logs it would be great. They should be in your users directory/.gitnuro or you can see them live by starting gitnuro from the command line.

Are you using Gitnuro from brew or downloaded the zip? If from the zip, have you installed libssh as the readme mentions? Otherwise please try to install Gitnuro using brew.

The logs may help in both cases.

happenpappen commented 1 year ago

I use the brew installation and think it's really the same issue as in #87 - when going through the log, i found (besides some exceptions) this message:

Native library (darwin-x86-64/libssh.dylib) not found in resource path

My MacBook has a M1 processor and is not x86 based... maybe this is the problem?

JetpackDuba commented 1 year ago

Ah damn, I didn't consider ARM would be an issue here. I'll have to check if there is a possible workaround or try to find a Mac with ARM to build.

Sorry for the inconvenience, developing for Mac is getting harder over time...

RomanSteinberg commented 11 months ago

I have the same problem with Pull and Push https://i.imgur.com/uaJQ5ex.png

Environment

GitNuro: 1.2.1 OS: Ubuntu 20.04 Git: 2.25.1

I had GitNuro previous year version (do not remember exactly) and everything was fine.

GitNuro log

2023-08-07 17:04:30 ERROR slf4j:16 - LibSshSession - Result is: 4.
Error is: Socket error: Connection refused
2023-08-07 17:04:30 ERROR slf4j:16 - TabState - ssh://git@gitlab.visionsystems.tech:2222/vision-systems/video-portal/backend.git: remote hung up unexpectedly
org.eclipse.jgit.api.errors.TransportException: ssh://git@gitlab.visionsystems.tech:2222/vision-systems/video-portal/backend.git: remote hung up unexpectedly
    at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:249)
    at org.eclipse.jgit.api.PullCommand.call(PullCommand.java:266)
    at com.jetpackduba.gitnuro.git.remote_operations.PullBranchUseCase$invoke$2.invokeSuspend(PullBranchUseCase.kt:27)
    at com.jetpackduba.gitnuro.git.remote_operations.PullBranchUseCase$invoke$2.invoke(PullBranchUseCase.kt)
    at com.jetpackduba.gitnuro.git.remote_operations.PullBranchUseCase$invoke$2.invoke(PullBranchUseCase.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.PullBranchUseCase.invoke(PullBranchUseCase.kt:15)
    at com.jetpackduba.gitnuro.viewmodels.MenuViewModel$pull$1.invokeSuspend(MenuViewModel.kt:35)
    at com.jetpackduba.gitnuro.viewmodels.MenuViewModel$pull$1.invoke(MenuViewModel.kt)
    at com.jetpackduba.gitnuro.viewmodels.MenuViewModel$pull$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: ssh://git@gitlab.visionsystems.tech:2222/vision-systems/video-portal/backend.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:153)
    at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:105)
    at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1462)
    at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:238)
    ... 24 more
Caused by: java.lang.Exception: Something went wrong with authentication. Code 4
    at com.jetpackduba.gitnuro.credentials.GRemoteSession.setup(GRemoteSession.kt:68)
    at com.jetpackduba.gitnuro.credentials.GSessionManager$generateSshSessionFactory$1.getSession(GSessionManager.kt:23)
    at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:107)
    at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:281)
    ... 29 more
2023-08-07 17:04:30 INFO  slf4j:8 - TabViewModel - Refreshing repository state SAFE

@JetpackDuba it is not Mac only problem.

JetpackDuba commented 11 months ago

@RomanSteinberg is this the JAR or the flatpak version?

RomanSteinberg commented 11 months ago

@RomanSteinberg is this the JAR or the flatpak version?

flatpak

JetpackDuba commented 11 months ago

Sorry for my late response @RomanSteinberg . The message is the same but the error is not (I should improve the message displayed). LibSSH seems to dislike something about your SSH config. Could you perhaps share it please? (You may want to obfuscate private data before sharing).

If you are not using a custom config there must be something different, I may ask you to try some development versions with additional logs flags.

RomanSteinberg commented 11 months ago

@JetpackDuba if you are talking about client config /etc/ssh/ssh_config then I want to say it is standard and I didn't change it after install. I can provide it if you ask.

If you mean user config /home/user/.ssh/config then I can assure you that I have some records like

Host server
    Hostname 111.111.111.111
    Port 11111
    User some_user
    ForwardAgent yes

Host aws-server
    Hostname ec2-numbers-and-letters.compute.amazonaws.com
    User aws_user
    ForwardAgent yes
    IdentityFile ~/.ssh/aws_key.pem

Also I'd like to mention that all other git tools work well. Even previous version of GitNuro. If you need some more information, please, ask.

Actually, I do not understand how my ssh config related to the problem. Does GitNuro use it? What for? I have no record about connecting to the git server I use in ssh config. And I do not need, because I posted public key in GitLab and that's all. Git works with repos it contains.

JetpackDuba commented 11 months ago

Because the config is read to know if there is anything that should be used.

Can you just try to rename the file and try again? I'd like to discard possible issues.

Escain commented 9 months ago

Hi @JetpackDuba,

I am very excited about getting v1.3 soon, so I wanted to have a look for this issue. On Linux (Debian with KDE desktop):

What I did: 1) Executed Gitnuro 1.2.0 2) Copied gitnuro ssh address 3) Used that to clone it (it asked me a password, which I entered any random)

I got somewhat a similiar issue: image

With the exact same "remote hung up unexpectedly"

Then I tried to clone manually with CLI "git" and got the ssh key authentication error. I created an appropriate ssh key on github and tried again -> All good.

Then I tried on Gitnuro, and could clone without errors.

Consequently, on my side:

JetpackDuba commented 9 months ago

Hey!

Yep, I'd like to improve the error messages but that means having to filter manually each possible exception type. I'll try to do it at least for the most popular errors.

JetpackDuba commented 9 months ago

If everything goes well, during the end of this week I'm going to release 1.3.0 that has libssh built statically so it does not depend on the host having it installed or using a different architecture (which would fix the issues in Apple ARM chips).