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

Can mina sshd be used in Android? #322

Closed
dllhxll opened this issue Feb 20, 2023 · 10 comments
Closed

Can mina sshd be used in Android? #322

dllhxll opened this issue Feb 20, 2023 · 10 comments
Labels
feature request A request for a new feature
Milestone

Comments

@dllhxll
Copy link

dllhxll commented Feb 20, 2023

Version

2.9.2

Bug description

I try to used mina sshd in Android but I have some problems:

  1. in LazyDefaultUserHomeFolderHolder, the path is read from System.getProperty("user.home"). But in Android, System.getProperty("user.home") is null. Will this be a problem?
  2. in ExceptionUtils, sshd uses class javax.management.MBeanException and javax.management.ReflectionException. But they don't exist on Android.

Can mina sshd be used in Android? Or is there any android version of sshd can be used in Android?

Actual behavior

  1. I change System.getProperty("user.home") to Environment.getExternalStorageDirectory().getAbsolutePath(). Otherwise, sshd can not connect to server.

Expected behavior

sshd can run in android

Relevant log output

No response

Other information

No response

@lgoldstein
Copy link
Contributor

We do not have many requests to run SSHD on Android, so we never invested any R&D on it. That being said, I believe that with a few tweaks (like the one suggested here), it could be made to support Android. Like I said, we do not have many requests to run SSHD on Android, and since our R&D resources are extremely low, we cannot really spend time on it. However, all is not lost - we welcome contributions, so if this piques your interest and you are willing to take the time, you can fork the project, make what changes you think are necessary and then submit a PR. We are more than willing to help with advice if you should need it.

lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Mar 23, 2023
lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Mar 23, 2023
lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Mar 23, 2023
lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Mar 23, 2023
lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Mar 23, 2023
lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Mar 24, 2023
lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Mar 24, 2023
lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Mar 24, 2023
lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Mar 24, 2023
lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Mar 24, 2023
lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Mar 24, 2023
lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Mar 24, 2023
lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Mar 24, 2023
lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Mar 24, 2023
lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Mar 24, 2023
lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Mar 24, 2023
lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Mar 24, 2023
lgoldstein pushed a commit to lgoldstein/mina-sshd that referenced this issue Mar 26, 2023
@tomaswolf tomaswolf added this to the 2.10 milestone Apr 8, 2023
@tomaswolf tomaswolf added the feature request A request for a new feature label Apr 8, 2023
amberin added a commit to amberin/orgzly-android-revived that referenced this issue Feb 12, 2024
This reverts commit e73d9f4.

If we use any JGit version above 6.2.x (as of this writing, the latest
available version is 6.8.0.202311291450-r), we run into this problem:
https://stackoverflow.com/questions/76549421/jgit-failure-in-cloning-repository.
Naturally, we don't want to raise minSdkVersion to 33.

But JGit 6.2.x depends on a version of the Apache MINA SSHD library
(2.8.0) which does not handle Android well (see
apache/mina-sshd#322). A later version
(2.10.0) added basic Android awareness, but that version is not used by
JGit until in v6.6.x.

We are thus stuck using JGit v5 until the Android support in JGit v6
improves.
amberin added a commit to amberin/orgzly-android-revived that referenced this issue Feb 13, 2024
This reverts commit e73d9f4.

If we use any JGit version above 6.2.x (as of this writing, the latest
available version is 6.8.0.202311291450-r), we run into this problem:
https://stackoverflow.com/questions/76549421/jgit-failure-in-cloning-repository.
Naturally, we don't want to raise minSdkVersion to 33.

But JGit 6.2.x depends on a version of the Apache MINA SSHD library
(2.8.0) which does not handle Android well (see
apache/mina-sshd#322). A later version
(2.10.0) added basic Android awareness, but that version is not used by
JGit until in v6.6.x.

We are thus stuck using JGit v5 until the Android support in JGit v6
improves.
@albertvaka
Copy link

albertvaka commented Aug 4, 2024

Hey, just FYI we do use mina-sshd in Android in the KDE Connect project 🙂

We just updated from v0.14.0 (from 10 years ago) to v2.13.1 😄

We haven't seen an issue with the Exceptions (yet?), but we did have to add a workaround to not use the user.home property.

Other than that, Mina SSHD runs quite well on Android. Since Android 11 (API version 30) it can run unmodified. On older versions it's not possible to use the NativeFileSystemFactory because to access the filesystem you have to use the Storage Access Framework API, so we had to implement our own FileSystemFactory using that, and we even went further and added more compatibility hacks to support down to Android 5.0, but you probably don't want to go that far.

@lgoldstein
Copy link
Contributor

On older versions it's not possible to use the NativeFileSystemFactory because to access the filesystem you have to use the Storage Access Framework API, so we had to implement our own FileSystemFactory

Can you publish the code somewhere and let us take a look at it ? Perhaps we can incorporate it into the standard MINA offering
Thx

@albertvaka
Copy link

The code is open source (GPL2 & GPL3) and can be found in https://invent.kde.org/network/kdeconnect-android/-/tree/master/src/org/kde/kdeconnect/Plugins/SftpPlugin

@lgoldstein
Copy link
Contributor

Great - thanks...

@tomaswolf
Copy link
Member

Probably you all are aware of this already and I'm making a fool of myself by stating the obvious :-) : the GPL (any version) is incompatible with the APL.

@albertvaka
Copy link

We could honestly re-license this portion of code if you guys really want it, but we had to make so many hacks to make it work in older Android versions that I honestly think you are better off supporting only Android 11+ (which only needs the home directory to be overridden to work out of the box).

@lgoldstein
Copy link
Contributor

Probably you all are aware of this already and I'm making a fool of myself by stating the obvious :-) : the GPL (any version) is incompatible with the APL.

I am aware of that (and you are not making a fool of yourself - it is an important observation). At this stage, I just wanted to take a look at the code and get a general impression of its underlying principles. If indeed we reach the decision to do something similar we will certainly need to review and resolve the licensing issues.

@lgoldstein
Copy link
Contributor

I honestly think you are better off supporting only Android 11+

I reached the same conclusion...

@ShellWen
Copy link
Contributor

ShellWen commented Aug 9, 2024

I did some work on #580

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A request for a new feature
Projects
None yet
Development

No branches or pull requests

5 participants