sshutil

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

README

ssh utils

Usage

package main

import (
    "github.com/oldthreefeng/algo/sshutil"
)

func main()  {
    s := sshutils.New()
    // Cmd is exec cmd on host
    s.Cmd(host, cmd)
    //CopyConfigFile is copy local file or bytes to remote file path
    s.CopyConfigFile(host, remoteFilePath , localFilePathOrBytes)
    // CopyRemoteFileToLocal is scp remote file to local
    s.CopyRemoteFileToLocal(host, localFilePath, remoteFilePath) 
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompressTar

func CompressTar(srcDirPath string, destFilePath string) error

func CompressZip

func CompressZip(fileDir string, outputPath string) error

CompressZip is compress all file in fileDir , and zip to outputPath like unix zip ./ -r a.zip

func FromLocal

func FromLocal(localPath string) string

Types

type SSH

type SSH struct {
	User       string
	Password   string
	PkFile     string
	PkPassword string
	Timeout    *time.Duration
}

func New

func New() *SSH

func (*SSH) Cmd

func (ss *SSH) Cmd(host string, cmd string) []byte

Cmd is in host exec cmd

func (*SSH) CmdToString

func (ss *SSH) CmdToString(host, cmd, spilt string) string

CmdToString is in host exec cmd and replace to spilt str

func (*SSH) Connect

func (ss *SSH) Connect(host string) (*ssh.Session, error)

func (*SSH) Copy

func (ss *SSH) Copy(host, localFilePath, remoteFilePath string)

Copy is

func (*SSH) CopyConfigFile

func (ss *SSH) CopyConfigFile(host, remoteFilePath string, localFilePathOrBytes interface{})

CopyConfigFile is copy local file or bytes to remote file path

func (*SSH) CopyForMD5

func (ss *SSH) CopyForMD5(host, localFilePath, remoteFilePath, md5 string) bool

Copy is

func (*SSH) CopyRemoteFileToLocal

func (ss *SSH) CopyRemoteFileToLocal(host, localFilePath, remoteFilePath string)

CopyRemoteFileToLocal is scp remote file to local

func (*SSH) Md5Sum

func (ss *SSH) Md5Sum(host, remoteFilePath string) string

Jump to

Keyboard shortcuts

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