How to get connection string for authentication callback in SSH in golang?

PHPz
Release: 2024-02-09 15:40:08
forward
979 people have browsed it

如何在 golang 中的 SSH 中获取身份验证回调的连接字符串?

php editor Youzi will introduce to you how to get the connection string of the authentication callback in SSH in golang. In the SSH protocol, the authentication callback is an important link, which is used to verify the client's identity and establish a secure connection. In order to obtain the connection string for the authentication callback, we can use the functions and methods provided by the ssh package in golang with the correct parameters and settings. In the following article, we will explain this process in detail to help you handle SSH connections and authentication flexibly in golang.

Question content

My server configuration code is:

serverConfig := ssh.ServerConfig{
        PublicKeyCallback: func(c ssh.ConnMetadata, pubKey ssh.PublicKey) (*ssh.Permissions, error) {
        ...
    }
}
Copy after login

I start the ssh connection using something like ssh://user@host:port/path. How do I get the path part of the ssh connection string in this callback or any other callback that can check the user key/password?

Solution

SSH is different from http, which contains ssh://user@host:port/path. The format is indeed user@host:port but it does not require ssh:// and path construction. In your question, PublicKeyCallback is using the public key. If you are performing a custom action, do it outside of PublicKeyCallback.

The above is the detailed content of How to get connection string for authentication callback in SSH in golang?. For more information, please follow other related articles on the PHP Chinese website!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!