pcal43 / fastback

Fast, incremental Minecraft world backups. Powered by Git.
https://pcal43.github.io/fastback/
GNU General Public License v2.0
125 stars 19 forks source link

Unability to use SSH keys from OpenSSH authentication agent #295

Closed RareScrap closed 8 months ago

RareScrap commented 10 months ago

Issue description

/backup full fails to push a branch to remote if the key was added with ssh-add command.

Steps to reproduce the issue

  1. Setup a fabric 1.20.2 server
  2. Install fastback-0.16.2+1.20.2-fabric.jar
  3. Install fabric-api-0.90.0+1.20.2.jar
  4. Generate a SSH key with ssh-keygen -t ed25519 -f ~/.ssh/fastback-ssh-key
  5. Add the key by executing the eval $(ssh-agent) and the ssh-add ~/.ssh/fastback-ssh-key
  6. Run the Minecraft server
  7. Execult /backup init
  8. Specify remote using backup set remote-url git@<SOME_STUFF>.git
  9. Execute /backup full

Expected result

Actual result

Additional details / screenshots

Full log ``` backup full [16:50:53] [Server thread/INFO]: Saving world before backup... [16:50:53] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:overworld [16:50:53] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:the_nether [16:50:53] [Server thread/INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:the_end [16:50:53] [Server thread/INFO]: ThreadedAnvilChunkStorage (world): All chunks are saved [16:50:53] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved [16:50:53] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved [16:50:53] [Server thread/INFO]: ThreadedAnvilChunkStorage: All dimensions are saved [16:50:53] [Server thread/INFO]: Backing up... [16:50:53] [pool-3-thread-2/INFO]: The server is starting a backup. [16:50:53] [pool-3-thread-2/INFO]: Creating backup snapshot 2023-10-09_16-50-53 [16:50:54] [pool-3-thread-2/INFO]: getOrCreateProvider(EdDSA) created instance of net.i2p.crypto.eddsa.EdDSASecurityProvider [16:50:54] [pool-3-thread-2/INFO]: No detected/configured IoServiceFactoryFactory; using Nio2ServiceFactoryFactory [16:50:55] [pool-3-thread-2/INFO]: Local backup succeeded but remote backup failed. See log for details. [16:50:55] [pool-3-thread-2/ERROR]: org.eclipse.jgit.api.errors.TransportException: git@gitlab.com:RareScrap/del21312.git: Cannot log in at gitlab.com:22 publickey: no keys to try java.io.IOException: org.eclipse.jgit.api.errors.TransportException: git@gitlab.com:RareScrap/del21312.git: Cannot log in at gitlab.com:22 publickey: no keys to try at net.pcal.fastback.repo.PushUtils.doPush(PushUtils.java:120) ~[fastback-0.16.2+1.20.2-fabric.jar:?] at net.pcal.fastback.repo.RepoImpl.doCommitAndPush(RepoImpl.java:104) ~[fastback-0.16.2+1.20.2-fabric.jar:?] at net.pcal.fastback.commands.FullCommand.lambda$run$1(FullCommand.java:65) ~[fastback-0.16.2+1.20.2-fabric.jar:?] at net.pcal.fastback.commands.Commands.lambda$gitOp$0(Commands.java:125) ~[fastback-0.16.2+1.20.2-fabric.jar:?] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?] at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?] at java.lang.Thread.run(Thread.java:833) ~[?:?] Caused by: org.eclipse.jgit.api.errors.TransportException: git@gitlab.com:RareScrap/del21312.git: Cannot log in at gitlab.com:22 publickey: no keys to try at org.eclipse.jgit.api.LsRemoteCommand.execute(LsRemoteCommand.java:192) ~[org_eclipse_jgit_org_eclipse_jgi309050840-r-a2ec4fe238df27f1.jar:?] at org.eclipse.jgit.api.LsRemoteCommand.call(LsRemoteCommand.java:131) ~[org_eclipse_jgit_org_eclipse_jgi309050840-r-a2ec4fe238df27f1.jar:?] at net.pcal.fastback.repo.PushUtils.doPush(PushUtils.java:87) ~[fastback-0.16.2+1.20.2-fabric.jar:?] ... 8 more Caused by: org.eclipse.jgit.errors.TransportException: git@gitlab.com:RareScrap/del21312.git: Cannot log in at gitlab.com:22 publickey: no keys to try at org.eclipse.jgit.transport.sshd.SshdSession.connect(SshdSession.java:182) ~[org_eclipse_jgit_org_eclipse_jgi309050840-r-5f19e0b51990461d.jar:?] at org.eclipse.jgit.transport.sshd.SshdSession.connect(SshdSession.java:101) ~[org_eclipse_jgit_org_eclipse_jgi309050840-r-5f19e0b51990461d.jar:?] at org.eclipse.jgit.transport.sshd.SshdSessionFactory.getSession(SshdSessionFactory.java:258) ~[org_eclipse_jgit_org_eclipse_jgi309050840-r-5f19e0b51990461d.jar:?] at org.eclipse.jgit.transport.sshd.SshdSessionFactory.getSession(SshdSessionFactory.java:1) ~[org_eclipse_jgit_org_eclipse_jgi309050840-r-5f19e0b51990461d.jar:?] at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:107) ~[org_eclipse_jgit_org_eclipse_jgi309050840-r-a2ec4fe238df27f1.jar:?] at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.(TransportGitSsh.java:279) ~[org_eclipse_jgit_org_eclipse_jgi309050840-r-a2ec4fe238df27f1.jar:?] at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:152) ~[org_eclipse_jgit_org_eclipse_jgi309050840-r-a2ec4fe238df27f1.jar:?] at org.eclipse.jgit.api.LsRemoteCommand.execute(LsRemoteCommand.java:170) ~[org_eclipse_jgit_org_eclipse_jgi309050840-r-a2ec4fe238df27f1.jar:?] at org.eclipse.jgit.api.LsRemoteCommand.call(LsRemoteCommand.java:131) ~[org_eclipse_jgit_org_eclipse_jgi309050840-r-a2ec4fe238df27f1.jar:?] at net.pcal.fastback.repo.PushUtils.doPush(PushUtils.java:87) ~[fastback-0.16.2+1.20.2-fabric.jar:?] ... 8 more Caused by: org.apache.sshd.common.SshException: No more authentication methods available at org.apache.sshd.common.future.AbstractSshFuture.verifyResult(AbstractSshFuture.java:141) ~[org_apache_sshd_sshd-common-2.10.0-fe3c193df90ae293.jar:?] at org.apache.sshd.client.future.DefaultAuthFuture.verify(DefaultAuthFuture.java:56) ~[org_apache_sshd_sshd-core-2.10.0-6fd515c6cdbd03ed.jar:?] at org.apache.sshd.client.future.DefaultAuthFuture.verify(DefaultAuthFuture.java:35) ~[org_apache_sshd_sshd-core-2.10.0-6fd515c6cdbd03ed.jar:?] at org.apache.sshd.common.future.VerifiableFuture.verify(VerifiableFuture.java:74) ~[org_apache_sshd_sshd-common-2.10.0-fe3c193df90ae293.jar:?] at org.eclipse.jgit.transport.sshd.SshdSession.connect(SshdSession.java:172) ~[org_eclipse_jgit_org_eclipse_jgi309050840-r-5f19e0b51990461d.jar:?] at org.eclipse.jgit.transport.sshd.SshdSession.connect(SshdSession.java:101) ~[org_eclipse_jgit_org_eclipse_jgi309050840-r-5f19e0b51990461d.jar:?] at org.eclipse.jgit.transport.sshd.SshdSessionFactory.getSession(SshdSessionFactory.java:258) ~[org_eclipse_jgit_org_eclipse_jgi309050840-r-5f19e0b51990461d.jar:?] at org.eclipse.jgit.transport.sshd.SshdSessionFactory.getSession(SshdSessionFactory.java:1) ~[org_eclipse_jgit_org_eclipse_jgi309050840-r-5f19e0b51990461d.jar:?] at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:107) ~[org_eclipse_jgit_org_eclipse_jgi309050840-r-a2ec4fe238df27f1.jar:?] at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.(TransportGitSsh.java:279) ~[org_eclipse_jgit_org_eclipse_jgi309050840-r-a2ec4fe238df27f1.jar:?] at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:152) ~[org_eclipse_jgit_org_eclipse_jgi309050840-r-a2ec4fe238df27f1.jar:?] at org.eclipse.jgit.api.LsRemoteCommand.execute(LsRemoteCommand.java:170) ~[org_eclipse_jgit_org_eclipse_jgi309050840-r-a2ec4fe238df27f1.jar:?] at org.eclipse.jgit.api.LsRemoteCommand.call(LsRemoteCommand.java:131) ~[org_eclipse_jgit_org_eclipse_jgi309050840-r-a2ec4fe238df27f1.jar:?] at net.pcal.fastback.repo.PushUtils.doPush(PushUtils.java:87) ~[fastback-0.16.2+1.20.2-fabric.jar:?] ... 8 more Caused by: org.apache.sshd.common.SshException: No more authentication methods available at org.apache.sshd.client.session.ClientUserAuthService.tryNext(ClientUserAuthService.java:390) ~[org_apache_sshd_sshd-core-2.10.0-6fd515c6cdbd03ed.jar:?] at org.apache.sshd.client.session.ClientUserAuthService.processUserAuth(ClientUserAuthService.java:331) ~[org_apache_sshd_sshd-core-2.10.0-6fd515c6cdbd03ed.jar:?] at org.apache.sshd.client.session.ClientUserAuthService.process(ClientUserAuthService.java:267) ~[org_apache_sshd_sshd-core-2.10.0-6fd515c6cdbd03ed.jar:?] at org.apache.sshd.common.session.helpers.CurrentService.process(CurrentService.java:109) ~[org_apache_sshd_sshd-core-2.10.0-6fd515c6cdbd03ed.jar:?] at org.apache.sshd.common.session.helpers.AbstractSession.doHandleMessage(AbstractSession.java:592) ~[org_apache_sshd_sshd-core-2.10.0-6fd515c6cdbd03ed.jar:?] at org.apache.sshd.common.session.helpers.AbstractSession.lambda$handleMessage$0(AbstractSession.java:523) ~[org_apache_sshd_sshd-core-2.10.0-6fd515c6cdbd03ed.jar:?] at org.apache.sshd.common.util.threads.ThreadUtils.runAsInternal(ThreadUtils.java:68) ~[org_apache_sshd_sshd-common-2.10.0-fe3c193df90ae293.jar:?] at org.apache.sshd.common.session.helpers.AbstractSession.handleMessage(AbstractSession.java:522) ~[org_apache_sshd_sshd-core-2.10.0-6fd515c6cdbd03ed.jar:?] at org.apache.sshd.common.session.helpers.AbstractSession.decode(AbstractSession.java:1649) ~[org_apache_sshd_sshd-core-2.10.0-6fd515c6cdbd03ed.jar:?] at org.apache.sshd.common.session.helpers.AbstractSession.messageReceived(AbstractSession.java:483) ~[org_apache_sshd_sshd-core-2.10.0-6fd515c6cdbd03ed.jar:?] at org.eclipse.jgit.internal.transport.sshd.JGitClientSession.messageReceived(JGitClientSession.java:208) ~[org_eclipse_jgit_org_eclipse_jgi309050840-r-5f19e0b51990461d.jar:?] at org.apache.sshd.common.session.helpers.AbstractSessionIoHandler.messageReceived(AbstractSessionIoHandler.java:64) ~[org_apache_sshd_sshd-core-2.10.0-6fd515c6cdbd03ed.jar:?] at org.apache.sshd.common.io.nio2.Nio2Session.handleReadCycleCompletion(Nio2Session.java:407) ~[org_apache_sshd_sshd-core-2.10.0-6fd515c6cdbd03ed.jar:?] at org.apache.sshd.common.io.nio2.Nio2Session$1.onCompleted(Nio2Session.java:380) ~[org_apache_sshd_sshd-core-2.10.0-6fd515c6cdbd03ed.jar:?] at org.apache.sshd.common.io.nio2.Nio2Session$1.onCompleted(Nio2Session.java:375) ~[org_apache_sshd_sshd-core-2.10.0-6fd515c6cdbd03ed.jar:?] at org.apache.sshd.common.io.nio2.Nio2CompletionHandler.lambda$completed$0(Nio2CompletionHandler.java:38) ~[org_apache_sshd_sshd-core-2.10.0-6fd515c6cdbd03ed.jar:?] at java.security.AccessController.doPrivileged(AccessController.java:318) ~[?:?] at org.apache.sshd.common.io.nio2.Nio2CompletionHandler.completed(Nio2CompletionHandler.java:37) ~[org_apache_sshd_sshd-core-2.10.0-6fd515c6cdbd03ed.jar:?] at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:129) ~[?:?] at sun.nio.ch.Invoker$2.run(Invoker.java:221) ~[?:?] at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:113) ~[?:?] ... 3 more ```
RareScrap commented 10 months ago

This fixes by providing .ssh/config file with the key:

# GitLab (Required by fastback minecraft mod)
Host gitlab.com
   HostName gitlab.com
   PreferredAuthentications publickey
   IdentityFile ~/.ssh/fastback-ssh-key

But there is no mention of it in wiki

RareScrap commented 10 months ago

Also, it's really strange that exceptions comes from the org.eclipse.jgit package. It seems not to happen because native git must be used as said in wiki:

If you already have git and git-lfs installed, native support will be enabled automatically when you run /backup init. -- Fastback wiki - How to Enable Native Git Support