0

I have a Linux box, that after connecting to remotely will prompt the user to complete 3 parameters that will log the user's session details, i.e. name, group, reason.

I have some Java that connects using the JSch library but I am not sure how to send the strings and keys (not commands) via the Session object to complete these parameters. How is this done?

Below is a segment of my script, where I am attempting to connect to the host and then execute the LS command, but of course before it can do this it will need to send the 3 user session detail parameters.

Properties config = App.getConfig(args);

    final PublicKeySshSession session = new PublicKeySshSession.Builder(
            config.getProperty("host"), 
            config.getProperty("username"), 
            Integer.parseInt(config.getProperty("port")), 
            config.getProperty("privateKeyPath")).logger(new JschLogger()).build();

    if (session == null) {
        System.exit(-1);
    }

    session.execute("ls");

}

I thought I would include this segement of the code to make it clearer what I am aiming to achieve.

6
  • PublicKeySshSession is not part of jsch, am I right, but your own class? Due to that, I don't see how your code snippet is useful. What actually would be useful is the actual output that you're getting for your ssh session asking for those details. Commented Dec 15, 2016 at 15:48
  • Yes it is my own class. I know it is only a segement of the script but I listed it to demonstrate what the script aims to achieve. I am really banging my head against the wall... Commented Dec 15, 2016 at 15:50
  • You could start with providing the log of what actually happens with the SSH session. Commented Dec 15, 2016 at 15:55
  • May I ask why you need the log? There won't be anything in there. The scripts falls over because it does not input the 3 session detail parameters. I would like to know if there is method for the session object to send the strings... Commented Dec 15, 2016 at 16:22
  • well, in the log there should be a prompt asking those 3 session detail parameters, right? Commented Dec 15, 2016 at 16:55

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.