webssh/src/main/java/net/educoder/bridge/webssh/controller/SshController.java

25 lines
870 B
Java

package net.educoder.bridge.webssh.controller;
import net.educoder.bridge.common.model.ApiResult;
import net.educoder.bridge.webssh.service.JchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/ssh")
public class SshController {
@Autowired
private JchService jchService;
@GetMapping("/exec")
public ApiResult<String> exec(String cmd,String username,String secret,String host,Integer port) throws Exception {
ApiResult<String> r = new ApiResult<>();
String s = jchService.sshCommand(host, port, username, secret, cmd);
r.setMsg("success");
r.setData(s);
return r;
}
}