Merge branch 'master' of github.com:go-gost/x
This commit is contained in:
@@ -5,12 +5,14 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/go-gost/core/dialer"
|
"github.com/go-gost/core/dialer"
|
||||||
md "github.com/go-gost/core/metadata"
|
md "github.com/go-gost/core/metadata"
|
||||||
ssh_util "github.com/go-gost/x/internal/util/ssh"
|
ssh_util "github.com/go-gost/x/internal/util/ssh"
|
||||||
"github.com/go-gost/x/registry"
|
"github.com/go-gost/x/registry"
|
||||||
"golang.org/x/crypto/ssh"
|
"golang.org/x/crypto/ssh"
|
||||||
|
"golang.org/x/crypto/ssh/agent"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -107,6 +109,11 @@ func (d *sshdDialer) initSession(ctx context.Context, addr string, conn net.Conn
|
|||||||
if d.md.signer != nil {
|
if d.md.signer != nil {
|
||||||
config.Auth = append(config.Auth, ssh.PublicKeys(d.md.signer))
|
config.Auth = append(config.Auth, ssh.PublicKeys(d.md.signer))
|
||||||
}
|
}
|
||||||
|
socket := os.Getenv("SSH_AUTH_SOCK")
|
||||||
|
if agentConn, err := net.Dial("unix", socket); err == nil {
|
||||||
|
agentClient := agent.NewClient(agentConn)
|
||||||
|
config.Auth = append(config.Auth, ssh.PublicKeysCallback(agentClient.Signers))
|
||||||
|
}
|
||||||
|
|
||||||
sshConn, chans, reqs, err := ssh.NewClientConn(conn, addr, &config)
|
sshConn, chans, reqs, err := ssh.NewClientConn(conn, addr, &config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user