Open devvthedev opened 2 weeks ago
It definitely should be possible to run without SSH directory.
The home directory is a bit more difficult since it is used in various places to do ~ substitution. It should fall back to FS.DETECTED.userHome()
, which in turn should use the Java user.home
, or in the very worst case the current directory at the time the application was started.
Explicitly setting the home directory to null should probably be forbidden.
I'll take a look, but the fix will not make it into the upcoming 7.0 release.
Hi @tomaswolf
It definitely should be possible to run without SSH directory.
Apologies, are you saying it's possible right now to configure it to run without SSH directory?
When I tried to exclude it in the factory builder by setting it to null or omitting it, the
factory.setSshDirectory(sshDirectory);
prevents that?
If it is currently possible, could you give me an example of how to configure it?
I'll take a look, but the fix will not make it into the upcoming 7.0 release.
Thank you ☺️ How would you suggest for now I configure the HomeDirectory until the fix makes it in?
Thank You!
It definitely should be possible to run without SSH directory.
Apologies, are you saying it's possible right now to configure it to run without SSH directory?
I'm saying that was the intent.
How would you suggest for now I configure the HomeDirectory until the fix makes it in?
Set it to any suitable directory. But choose one where you don't get files downloaded from the Internet.
I'm saying that was the intent.
I've looked through the code and places that use the sshDir will have been overridden by other config on the builder we discussed earlier. (setServerKeyDatabase, ConfigStoreFactory etc.)
Are we saying that the setter of the ssh directory on the sshhSessionFactory should/will be made nullable?
Set it to any suitable directory.
Would a temporary directory work?
Will this temporary fix also be the case for setting the SshDirectory on the builder? So I should set both HomeDirectory and SshDirectory on the builder to this other suitable directory that is not the Git root directory?
Thanks
Version
6.10.0.202406032230-r
Operating System
MacOS
Bug description
I want to build a SshdSessionFactory using the SshdSessionFactoryBuilder specifying an SSH key pair programatically without needing to set what Home Directory and SSH folder are.
"It should be possible to run this without any files"
As mentioned in https://github.com/apache/mina-sshd/issues/532 specifically here, I am unable to build a
SshdSessionFactory
using theSshdSessionFactoryBuilder
without being forced to specify the File location for both HomeDirectory and SshDirectory.This can be reproduced by building a SshdSessionFactory using the SshdSessionFactoryBuilder.
When constructing an SshdSessionFactoryBuilder with:
.setHomeDirectory(null)
and.setSshDirectory(null)
(or omitting entirely)
e.g.
I am required to set both HomeDirectory and SshDirectory to some directory despite providing my key pair through the
.setDefaultKeysProvider(ignoredSshDirBecauseWeUseAnInMemorySetOfKeyPairs -> keyPairs)
builder method.Actual behavior
A null pointer exception is thrown saying that the HomeDirectory and SshDirectory cannot be null.
When invoking
.build
on the builder, the following setters for these directories are called:Both the SSH directory and HomeDirectory are required to be non null:
SshdSessionFactory.setHomeDirectory SshdSessionFactory.setSshDirectory
Expected behavior
To not have to provide an SSH Directory or Home Directory to the builder.
I provide the following to the builder:
Which should mean these directories are not required to be specified as they are not used when creating a session.
Relevant log output
Other information
Reference: https://github.com/apache/mina-sshd/issues/532
CC: @tomaswolf