ssh

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(hostname string, user string, port int, authConfig AuthConfig) error

Connect 连接到服务器并执行命令(交互式,全部通过 expect 实现)

func CopyFile

func CopyFile(client *ssh.Client, localPath string, remotePath string) error

CopyFile 通过SSH复制文件(已弃用,使用scp命令代替) 保留此方法以保持API兼容性,但实际实现已改用系统scp命令

func ExecuteCommand

func ExecuteCommand(client *ssh.Client, command string) (string, error)

ExecuteCommand 在远程服务器执行命令

func NewSSHClient

func NewSSHClient(hostname string, user string, port int, authConfig AuthConfig) (*ssh.Client, error)

NewSSHClient 创建SSH客户端(用于程序化操作,非交互式登录)

Types

type AuthConfig

type AuthConfig struct {
	Type         string
	Password     string
	IdentityFile string
}

AuthConfig 认证配置(从config包导入的类型)

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client SSH客户端封装

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL