MCPcopy Create free account
hub / github.com/appleboy/easyssh-proxy / main

Function main

_examples/ssh/ssh.go:10–53  ·  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 // Optional key or Password without either we try to contact your agent SOCKET
16 // Password: "password",
17 // Paste your source content of private key
18 // Key: `-----BEGIN RSA PRIVATE KEY-----
19 // MIIEpAIBAAKCAQEA4e2D/qPN08pzTac+a8ZmlP1ziJOXk45CynMPtva0rtK/RB26
20 // 7XC9wlRna4b3Ln8ew3q1ZcBjXwD4ppbTlmwAfQIaZTGJUgQbdsO9YA==
21 // -----END RSA PRIVATE KEY-----
22 // `,
23 KeyPath: "/Users/username/.ssh/id_rsa",
24 Port: "22",
25 Timeout: 60 * time.Second,
26
27 // Parse PrivateKey With Passphrase
28 Passphrase: "1234",
29
30 // Optional fingerprint SHA256 verification
31 // Get Fingerprint: ssh.FingerprintSHA256(key)
32 // Fingerprint: "SHA256:mVPwvezndPv/ARoIadVY98vAC0g+P/5633yTC4d/wXE"
33
34 // Enable the use of insecure ciphers and key exchange methods.
35 // This enables the use of the the following insecure ciphers and key exchange methods:
36 // - aes128-cbc
37 // - aes192-cbc
38 // - aes256-cbc
39 // - 3des-cbc
40 // - diffie-hellman-group-exchange-sha256
41 // - diffie-hellman-group-exchange-sha1
42 // Those algorithms are insecure and may allow plaintext data to be recovered by an attacker.
43 // UseInsecureCipher: true,
44 }
45
46 // Call Run method with command you want to run on remote server.
47 stdout, stderr, done, err := ssh.Run("ls -al", 60*time.Second)
48 // Handle errors
49 if err != nil {
50 panic("Can't run remote command: " + err.Error())
51 }
52 fmt.Println("don is :", done, "stdout is :", stdout, "; stderr is :", stderr)
53}

Callers

nothing calls this directly

Calls 1

RunMethod · 0.95

Tested by

no test coverage detected