Compare commits

..

No commits in common. "jsx_231016" and "master" have entirely different histories.

1 changed files with 4 additions and 16 deletions

View File

@ -10,7 +10,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import com.jcraft.jsch.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -19,6 +18,10 @@ import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketSession;
import com.alibaba.fastjson.JSONObject;
import com.jcraft.jsch.ChannelShell;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
import com.jcraft.jsch.UserInfo;
import net.educoder.bridge.webssh.model.ConnectInfo;
import net.educoder.bridge.webssh.model.WebscoketObj;
@ -171,10 +174,6 @@ public class JchService {
session.setServerAliveInterval(30 * 1000); // 30秒心跳一次用于保活
session.connect();
//本次ssh导入环境变量
executeCommend(session, "export $(cat /proc/1/environ |tr '\0' '\n' |grep -v ' ' | xargs)");
ChannelShell channel = (ChannelShell) session.openChannel("shell");
channel.setPtyType("xterm");
@ -311,15 +310,4 @@ public class JchService {
}
return null;
}
private void executeCommend(Session session, String cmd){
try {
ChannelExec channelExec = (ChannelExec) session.openChannel("exec");
channelExec.setCommand(cmd);
channelExec.connect();
// 关闭ChannelExec
channelExec.disconnect();
}catch (Exception ignore){}
}
}