Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jsch session Configuration

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.

like image 897
rogue-one Avatar asked Aug 27 '14 11:08

rogue-one


People also ask

What is session in JSch?

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() .

What is StrictHostKeyChecking in JSch?

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.

Is JSch maintained?

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.

How do I close a JSch session?

jsch. Session#disconnect() .


1 Answers

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.

like image 116
Kenster Avatar answered Oct 01 '22 17:10

Kenster