Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSSHConfig ¶
func NewSSHConfig(config Config) (*ssh.ClientConfig, error)
NewSSHConfig 根据提供的配置生成SSH客户端配置。 它支持通过密码、私钥内容或私钥文件路径三种方式来创建SSH连接。
参数
- config: 包含了SSH连接所需的配置信息,包括用户类型、密码、私钥等。
返回值:
- *ssh.ClientConfig 类型的SSH客户端配置指针,以及可能的错误信息。
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 结构体代表一个SSH客户端连接,它包含了一个指向ssh.Client的指针。
type Config ¶
type Config struct { // Host SSH远程主机的IP地址或域名 Host string // Port SSH远程主机的连接端口 Port int // Type SSH连接的认证类型,包括密码、私钥内容或私钥文件路径三种方式 Type ConfigType // User SSH远程主机的登录用户名 User string // Password SSH远程主机的登录密码,仅在Type为ConfigTypeByPassword时生效 Password string // PrivateKey SSH远程主机的私钥内容,仅在Type为ConfigTypeByPrivateKey时生效 PrivateKey string // PrivateKeyPath SSH远程主机的私钥文件路径,仅在Type为ConfigTypeByPrivateKeyPath时生效 PrivateKeyPath string }
Config SSH连接配置信息结构体
type ConfigType ¶
type ConfigType uint8
ConfigType ssh 连接支持的类型
const ( // ConfigTypeByPassword 表示通过密码进行配置 ConfigTypeByPassword ConfigType = iota // ConfigTypeByPrivateKey 表示通过私钥进行配置 ConfigTypeByPrivateKey // ConfigTypeByPrivateKeyPath 表示通过私钥路径进行配置 ConfigTypeByPrivateKeyPath )
Click to show internal directories.
Click to hide internal directories.