- private Option portOption;
-
- @Override
- public Options getOptions() {
- Options options = new Options();
- portOption = Option.builder().option("p").longOpt("port").hasArg().desc("port to connect to").build();
- options.addOption(portOption);
- return options;
- }
-
- @Override
- public String apply(List<String> args) {
- CommandLine cl = toCommandLine(args);
- String portStr = cl.getOptionValue(portOption);
- if (portStr == null)
- portStr = "22";
-
- String host = cl.getArgList().get(0);
-
- String uriStr = "ssh://" + host + ":" + portStr + "/";
- // System.out.println(uriStr);
- URI uri = URI.create(uriStr);
-
- Ssh ssh = null;
+ private Option portOption;
+
+ @Override
+ public Options getOptions() {
+ Options options = new Options();
+ portOption = Option.builder().option("p").longOpt("port").hasArg().desc("port to connect to").build();
+ options.addOption(portOption);
+ return options;
+ }
+
+ @Override
+ public String apply(List<String> args) {
+ CommandLine cl = toCommandLine(args);
+ String portStr = cl.getOptionValue(portOption);
+ if (portStr == null)
+ portStr = "22";
+
+ if (cl.getArgList().size() == 0)
+ throw new CommandArgsException("Host must be provided");
+ String host = cl.getArgList().get(0);
+
+ String uriStr = "ssh://" + host + ":" + portStr + "/";
+ // System.out.println(uriStr);
+ URI uri = URI.create(uriStr);
+
+ Ssh ssh = null;
+ try {
+ ssh = new Ssh(uri);
+ boolean osAgent;
+ SshAgent sshAgent;