对 Apache mina sshd 服务器执行 ssh 命令

问题描述

我已经使用 apache mina 库在 Windows 机器上设置了本地 sshd 服务器。

这是一个与他们 GitHub 存储库下使用的示例类似的基本示例。

SshServer sshserver = SshServer.setUpDefaultServer();
if (SecurityUtils.isBouncyCastleRegistered()) {
            sshserver.setKeyPairProvider(new PEMGeneratorHostKeyProvider("key.pem"));
        } else {
            sshserver.setKeyPairProvider(new SimpleGeneratorHostKeyProvider());
        }
sshserver.setPort(DEFAULT_PORT);
sshserver.setShellFactory(new ProcessShellFactory(new String[]{"cmd.exe "},EnumSet.of(ProcessShellFactory.TtyOptions.Echo,ProcessShellFactory.TtyOptions.ICrNl,ProcessShellFactory.TtyOptions.ONlCr)));
sshserver.setPasswordAuthenticator(new PasswordAuthenticator());
sshserver.start();

一旦它启动并运行,我就可以连接到服务器并正常运行命令。

但是一旦我尝试像这样远程运行命令: ssh -p <port_number> <username>@<local_ip> dir

ssh 关闭了连接,并且在 sshd 日志上我收到了 Command not Found 异常。

有没有人设法在 ssh mina apache 服务器上运行这样的远程 ssh 命令?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)