VERTX外壳的身份验证

发布于 2025-02-06 15:12:18 字数 3849 浏览 1 评论 0原文

我一直在尝试使用VERTX Shell制作命令行应用程序。但是,当我尝试使用SSH身份验证将其连接到它时,我会面临与外壳连接的麻烦。据我所知,我已经遵循了文档中提供的所有步骤,但仍然无法弄清楚为什么我拒绝尝试连接到壳牌的权限。 以下是我用来启动Shell Server的狙击手:

    class ShellVerticle :  CoroutineVerticle() {
    @Throws(Exception::class)
    override suspend fun start() {
        logger.debug("Staring vertx shell")
        val shellOptions = ShellServiceOptions()
            .apply { welcomeMessage = "\nWelcome to Logging Shell Shell\n\n" }
        val shellServer = ShellServer.create(vertx, shellOptions).apply {
            val authProps = JsonObject()
                .put("properties_path", "classpath:shell.properties")
            println(authProps.json)
            val sshTermServer = TermServer.createSSHTermServer(vertx, SSHTermOptions().apply {
                host = "localhost"
                port = 5001
                setKeyPairOptions(JksOptions().setPath("vertx-shell-1.8.jks").setPassword("123456"))
                authOptions = JsonObject().put("provider", "shiro").put("config", authProps)
            })
 
            registerTermServer(sshTermServer)
            listen { res ->
                if (res.failed())
                    res.cause().printStackTrace()
                else
                    logger.info("Logging shell started successfully")
            }
 
        }
        shellServer.registerCommandResolver { listOf(Help::class.java, TraceCommand::class.java).map { Command.create(vertx, it) } }
        logger.info("Commands Registered")
 
    }
}

运行此操作后的控制台上的日志:

INFO  | 11:31:09 | [main] example.TracerKt (Main.kt:7) - Going to start Shell Verticle
WARN  | 11:31:13 | [vertx-blocked-thread-checker] impl.BlockedThreadChecker (:) - Thread Thread[vert.x-eventloop-thread-1,5,main] has been blocked for 2212 ms, time limit is 2000 ms
{"map":{"properties_path":"classpath:shell.properties"},"empty":false}
INFO  | 11:31:13 | [vert.x-eventloop-thread-1] example.TracerKt (ShellVerticle.kt:73) - Commands Registered
INFO  | 11:31:14 | [vert.x-eventloop-thread-0] example.TracerKt (Main.kt:9) - Going to start Logger Verticle
INFO  | 11:31:17 | [vert.x-eventloop-thread-1] logging.LoggingHandler (Log4J2Logger.java:99) - [id: 0x35e8004c] REGISTERED
INFO  | 11:31:17 | [vert.x-eventloop-thread-1] logging.LoggingHandler (Log4J2Logger.java:99) - [id: 0x35e8004c] BIND: localhost/127.0.0.1:5001
INFO  | 11:31:17 | [vert.x-eventloop-thread-1] logging.LoggingHandler (Log4J2Logger.java:99) - [id: 0x35e8004c, L:/127.0.0.1:5001] ACTIVE
INFO  | 11:31:17 | [vert.x-eventloop-thread-1] logging.LoggingHandler (Log4J2Logger.java:99) - [id: 0x27d1d899] REGISTERED
INFO  | 11:31:17 | [vert.x-eventloop-thread-1] logging.LoggingHandler (Log4J2Logger.java:99) - [id: 0x27d1d899] BIND: localhost/0:0:0:0:0:0:0:1:5001
INFO  | 11:31:17 | [vert.x-eventloop-thread-1] logging.LoggingHandler (Log4J2Logger.java:99) - [id: 0x27d1d899, L:/0:0:0:0:0:0:0:1:5001] ACTIVE
INFO  | 11:31:17 | [vert.x-eventloop-thread-1] example.TracerKt (ShellVerticle.kt:67) - Logging shell started successfully

属性文件:

user.billy=test,admin
role.admin=*

我尝试连接到Shell时获得的输出:

C:\Users\abhrdas>ssh -p 5001 billy@localhost
Password authentication
Password:
Password authentication
Password:
Password authentication
Password:
billy@localhost's password:
Permission denied, please try again.
billy@localhost's password:
Permission denied, please try again.
billy@localhost's password:
billy@localhost: Permission denied (password,keyboard-interactive,publickey).

请帮助我。 如果您不能至少可以确认Shell Verticle的代码是否正确,并且如果我能够以某种方式解决此问题,我注册的命令将可用?这些命令已经使用了Telnet协议,但是我无法使用SSH协议运行Shell。 理想情况下,我应该输入控制台中两个不同密码的内容,因为我仅将测试设置为用户的密码,但是控制台要求我提供两个不同的密码。 我真的遇到了这个问题,请帮忙。 谢谢。

I have been trying to make a command line application using vertx shell. But I am facing troubles in connecting to my shell when I am trying to connect to it using ssh authentication. I have followed all the steps that are provided in the documentation, to the best of my knowledge but still can't figure out why I am getting permission denied on trying to connect to the shell.
Below is the snipper I have used to start the shell server:

    class ShellVerticle :  CoroutineVerticle() {
    @Throws(Exception::class)
    override suspend fun start() {
        logger.debug("Staring vertx shell")
        val shellOptions = ShellServiceOptions()
            .apply { welcomeMessage = "\nWelcome to Logging Shell Shell\n\n" }
        val shellServer = ShellServer.create(vertx, shellOptions).apply {
            val authProps = JsonObject()
                .put("properties_path", "classpath:shell.properties")
            println(authProps.json)
            val sshTermServer = TermServer.createSSHTermServer(vertx, SSHTermOptions().apply {
                host = "localhost"
                port = 5001
                setKeyPairOptions(JksOptions().setPath("vertx-shell-1.8.jks").setPassword("123456"))
                authOptions = JsonObject().put("provider", "shiro").put("config", authProps)
            })
 
            registerTermServer(sshTermServer)
            listen { res ->
                if (res.failed())
                    res.cause().printStackTrace()
                else
                    logger.info("Logging shell started successfully")
            }
 
        }
        shellServer.registerCommandResolver { listOf(Help::class.java, TraceCommand::class.java).map { Command.create(vertx, it) } }
        logger.info("Commands Registered")
 
    }
}

The log on the console after running this:

INFO  | 11:31:09 | [main] example.TracerKt (Main.kt:7) - Going to start Shell Verticle
WARN  | 11:31:13 | [vertx-blocked-thread-checker] impl.BlockedThreadChecker (:) - Thread Thread[vert.x-eventloop-thread-1,5,main] has been blocked for 2212 ms, time limit is 2000 ms
{"map":{"properties_path":"classpath:shell.properties"},"empty":false}
INFO  | 11:31:13 | [vert.x-eventloop-thread-1] example.TracerKt (ShellVerticle.kt:73) - Commands Registered
INFO  | 11:31:14 | [vert.x-eventloop-thread-0] example.TracerKt (Main.kt:9) - Going to start Logger Verticle
INFO  | 11:31:17 | [vert.x-eventloop-thread-1] logging.LoggingHandler (Log4J2Logger.java:99) - [id: 0x35e8004c] REGISTERED
INFO  | 11:31:17 | [vert.x-eventloop-thread-1] logging.LoggingHandler (Log4J2Logger.java:99) - [id: 0x35e8004c] BIND: localhost/127.0.0.1:5001
INFO  | 11:31:17 | [vert.x-eventloop-thread-1] logging.LoggingHandler (Log4J2Logger.java:99) - [id: 0x35e8004c, L:/127.0.0.1:5001] ACTIVE
INFO  | 11:31:17 | [vert.x-eventloop-thread-1] logging.LoggingHandler (Log4J2Logger.java:99) - [id: 0x27d1d899] REGISTERED
INFO  | 11:31:17 | [vert.x-eventloop-thread-1] logging.LoggingHandler (Log4J2Logger.java:99) - [id: 0x27d1d899] BIND: localhost/0:0:0:0:0:0:0:1:5001
INFO  | 11:31:17 | [vert.x-eventloop-thread-1] logging.LoggingHandler (Log4J2Logger.java:99) - [id: 0x27d1d899, L:/0:0:0:0:0:0:0:1:5001] ACTIVE
INFO  | 11:31:17 | [vert.x-eventloop-thread-1] example.TracerKt (ShellVerticle.kt:67) - Logging shell started successfully

The properties file:

user.billy=test,admin
role.admin=*

The output I get when I try to connect to shell:

C:\Users\abhrdas>ssh -p 5001 billy@localhost
Password authentication
Password:
Password authentication
Password:
Password authentication
Password:
billy@localhost's password:
Permission denied, please try again.
billy@localhost's password:
Permission denied, please try again.
billy@localhost's password:
billy@localhost: Permission denied (password,keyboard-interactive,publickey).

Picture of my command line

Please help me with this.
If you can't can you at least please confirm if the code for the Shell Verticle is correct and the commands I have registered will be available if I am somehow able to solve this issue? The commands were already working with the telnet protocol but I haven't been able to run the shell with the ssh protocol.
Also ideally what should I enter for the two different passwords in the console, as I have set only test as the password for the user but the console is asking me for two different passwords.
I am really stuck at this problem, please do help.
Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文