feat: add identity_file field to config connections config

This commit is contained in:
Connor Edwards
2025-02-08 15:56:18 +00:00
parent e3a310397b
commit ac48b8bee6
5 changed files with 57 additions and 11 deletions
+6 -2
View File
@@ -2,12 +2,13 @@ package sshexec
import (
"fmt"
"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/agent"
"net"
"os"
"strconv"
"time"
"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/agent"
)
func Connect(user, host string, port int, sshKeyPath string) (*ssh.Client, error) {
@@ -34,6 +35,9 @@ func Connect(user, host string, port int, sshKeyPath string) (*ssh.Client, error
}
keyAuth, err := privateKeyAuth(sshKeyPath)
if err != nil {
return nil, err
}
config := &ssh.ClientConfig{
User: user,
Auth: []ssh.AuthMethod{keyAuth},