Documentation
¶
Index ¶
- Constants
- func Cat(s SshSetting, path string) (string, error)
- func Chmod(s SshSetting, path string, permission string, format bool) (e error)
- func Chown(s SshSetting, path string, user string, group string, recursive bool) error
- func List(s SshSetting, path string, isParseble bool) (string, error)
- func MakeDir(s SshSetting, path string, permission string) error
- func MakeFile(s SshSetting, content string, path string, permission string, format bool) error
- func PublicKeyFile(file string) ssh.AuthMethod
- func Remove(s SshSetting, recursive bool, paths ...string) map[string]error
- func Rename(s SshSetting, oldPath string, newPath string) error
- func Search(s SshSetting, path string, isParseble bool, search string) (string, error)
- func TermInOut(w io.Writer, r io.Reader) (chan<- string, <-chan string)
- type RunCommandResult
- type SSHAuthTypeEnum
- type SshSetting
- func (S *SshSetting) Connect() (*ssh.Client, error)
- func (s *SshSetting) GetOutputCommandSsh(cmd string) (string, error)
- func (s *SshSetting) NewSession() (*ssh.Client, *ssh.Session, error)
- func (S *SshSetting) RunCommandSsh(cmds ...string) (string, error)
- func (s *SshSetting) RunCommandSshAsMap(cmds ...string) ([]RunCommandResult, error)
- func (S *SshSetting) SshCopyByFile(content io.Reader, size int64, perm os.FileMode, filename string, ...) error
- func (S *SshSetting) SshCopyByPath(filePath, destinationPath string) error
- func (S *SshSetting) SshGetFile(path string) (res bytes.Buffer, e error)
Constants ¶
View Source
const ( LIST = "ls -l %v" LIST_PARAM = "ls -l %v | awk '{ print $1,\"||\",$2,\"||\",$3,\"||\",$4,\"||\",$5,\"||\",$6,\"||\",$7,\"||\",$8,\"||\",$9,$10,$11}'" SEARCH = "find %v -name *%v* -ls | awk '{print $3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13}'" SEARCH_PARAM = "" /* 132-byte string literal not displayed */ // SEARCH = "find %v -name *%v* | xargs -r -l ls -l" // SEARCH_PARAM = "find %v -name *%v* | xargs -r -l ls -l | awk '{ print $1,\"||\",$2,\"||\",$3,\"||\",$4,\"||\",$5,\"||\",$6,\"||\",$7,\"||\",$8,\"||\",$9,$10,$11}'" // SEARCH = "ls -l -R %s | grep %s" // SEARCH_PARAM = "ls -l -R %s | grep %s | awk '{ print $1,\"||\",$2,\"||\",$3,\"||\",$4,\"||\",$5,\"||\",$6,\"||\",$7,\"||\",$8,\"||\",$9,$10,$11}'" MKDIR = "mkdir -m %v '%v'" REMOVE = "rm -f %v" REMOVE_RECURSIVE = "rm -R -f %v" RENAME = "mv '%v' '%v'" MKFILE = "echo \"%v\" > '%v'" CHMOD = "chmod %v %v" CHOWN = "chwon %v:%v %v" CHOWN_RECURSIVE = "chwon -R %v:%v %v" CAT = "cat %v" )
Variables ¶
This section is empty.
Functions ¶
func PublicKeyFile ¶
func PublicKeyFile(file string) ssh.AuthMethod
Parsing private key certicate using for connection over ssh
Types ¶
type RunCommandResult ¶
type SSHAuthTypeEnum ¶
type SSHAuthTypeEnum int
const ( //Type authentication login in ssh, it can using password or using public-private key SSHAuthType_Password SSHAuthTypeEnum = iota SSHAuthType_Certificate )
type SshSetting ¶
type SshSetting struct { //Setting information for ssh connection SSHHost string SSHUser string SSHPassword string SSHKeyLocation string SSHAuthType SSHAuthTypeEnum SSHDebug bool }
func (*SshSetting) Connect ¶
func (S *SshSetting) Connect() (*ssh.Client, error)
Build connection ssh client to ssh server
func (*SshSetting) GetOutputCommandSsh ¶
func (s *SshSetting) GetOutputCommandSsh(cmd string) (string, error)
Run single command, get the output
func (*SshSetting) NewSession ¶
Create new session
func (*SshSetting) RunCommandSsh ¶
func (S *SshSetting) RunCommandSsh(cmds ...string) (string, error)
Build connection and run ssh script, catch the output or give error message if any
func (*SshSetting) RunCommandSshAsMap ¶
func (s *SshSetting) RunCommandSshAsMap(cmds ...string) ([]RunCommandResult, error)
Build connection and run ssh script, catch the output or give error message if any
func (*SshSetting) SshCopyByFile ¶
func (*SshSetting) SshCopyByPath ¶
func (S *SshSetting) SshCopyByPath(filePath, destinationPath string) error
Copy file adopted from https://github.com/tmc/scp/blob/master/scp.go
func (*SshSetting) SshGetFile ¶
func (S *SshSetting) SshGetFile(path string) (res bytes.Buffer, e error)
Click to show internal directories.
Click to hide internal directories.