I have the following as shown below in my ssh config file. I will have to set the same configuration to my Jsch session. Jsch supports setting configs as below
session.setConfig(String name, String value);
session.setConfig(HashTable config);
session.setConfig(Properties config);
But none doesn't seems to support hierarchal nested setting (i.e Settings applicable only for a range of Hosts)
Host git.*
User git
ProxyCommand ssh -q github.example.com nc git %p
Open to alternative suggestions such as creating SSH Tunnels or others.
A Session represents a connection to a SSH server. One session can contain multiple Channel s of various types, created with openChannel(java. lang. String) . A session is opened with connect() and closed with disconnect() .
StrictHostKeyChecking values: ask | yes | no. default: ask. If this property is set to yes, JSch will never automatically add host keys to the $HOME/. ssh/known_hosts file, and refuses to connect to hosts whose host key has changed. This property forces the user to manually add all new hosts.
for our customers, so we have strong motivations to continue it. So, yes, we will continue maintaining jsch. At present time, there is not a public repository, and we will accept bug reports at jsch-users mailing list.
jsch. Session#disconnect() .
You may be suffering under a misapprehension that Jsch is a java version of the ssh
command-line utility. Jsch is an implementation of the SSH protocol. You could use it to build a command-line utility, but it doesn't implement every feature of the command-line utility that's not related to the protocol itself.
Here is a sample page listing the config options which Jsch accepts. One thing you'll notice is that the list doesn't look anything like the ssh config options. If you want to support ssh-style options, you will probably find it necessary to write your own code to interpret and implement them.
To implement host-specific options, your client program would have to know which host it is connecting to and which options should be applied to that host.
Regarding the default user, the remote username is a parameter that your code would supply to Jsch when calling the function to open an SSH session. If you want to have a default user feature, you'd have to write that feature into your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With