MCPcopy Index your code
hub / github.com/appleboy/easyssh-proxy / main

Function main

_examples/writeFile/writeFile.go:10–28  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8)
9
10func main() {
11 // Create MakeConfig instance with remote username, server address and path to private key.
12 ssh := &easyssh.MakeConfig{
13 User: "appleboy",
14 Server: "example.com",
15 KeyPath: "/Users/username/.ssh/id_rsa",
16 Port: "22",
17 Timeout: 60 * time.Second,
18 }
19
20 fileContents := "Example Text..."
21 reader := strings.NewReader(fileContents)
22
23 // Write a file to the remote server using the writeFile command.
24 // Second arguement specifies the number of bytes to write to the server from the reader.
25 if err := ssh.WriteFile(reader, int64(len(fileContents)), "/home/user/foo.txt"); err != nil {
26 panic("Error: failed to write file to client")
27 }
28}

Callers

nothing calls this directly

Calls 1

WriteFileMethod · 0.95

Tested by

no test coverage detected