Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion api/client/proxy/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,11 @@ func (c *Client) ClientConfig(ctx context.Context, cluster string) (client.Confi
func (c *Client) DialHost(ctx context.Context, target, cluster string, keyring agent.ExtendedAgent) (net.Conn, ClusterDetails, error) {
conn, details, err := c.transport.DialHost(ctx, target, cluster, nil, keyring)
if err != nil {
return nil, ClusterDetails{}, trace.ConnectionProblem(err, "failed connecting to host %s: %v", target, err)
host := target
if h, _, err := net.SplitHostPort(target); err == nil {
host = h
}
return nil, ClusterDetails{}, trace.ConnectionProblem(err, "failed connecting to host %s: %v", host, err)
}

return conn, ClusterDetails{FIPS: details.FipsEnabled}, nil
Expand Down
6 changes: 3 additions & 3 deletions api/client/proxy/transport/transportv1/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,21 +245,21 @@ func (c *Client) DialHost(ctx context.Context, hostport, cluster string, src net
stream, err := c.clt.ProxySSH(ctx)
if err != nil {
cancel()
return nil, nil, trace.Wrap(err, "unable to establish proxy stream")
return nil, nil, trace.Wrap(err, "opening proxy stream")
}

if err := stream.Send(&transportv1pb.ProxySSHRequest{DialTarget: &transportv1pb.TargetHost{
HostPort: hostport,
Cluster: cluster,
}}); err != nil {
cancel()
return nil, nil, trace.Wrap(err, "failed to send dial target request")
return nil, nil, trace.Wrap(err, "sending dial target request")
}

resp, err := stream.Recv()
if err != nil {
cancel()
return nil, nil, trace.Wrap(err, "failed to receive cluster details response")
return nil, nil, trace.Wrap(err)
}

// create streams for ssh and agent protocol
Expand Down
2 changes: 1 addition & 1 deletion integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2292,7 +2292,7 @@ func testInvalidLogins(t *testing.T, suite *integrationTestSuite) {
require.NoError(t, err)

err = tc.SSH(context.Background(), cmd)
require.ErrorIs(t, err, trace.NotFound("failed to dial target host\n\tlooking up remote cluster \"wrong-site\"\n\t\tnot found"))
require.ErrorContains(t, err, "failed connecting to host localhost: looking up remote cluster \"wrong-site\"\n\tnot found")
}

// TestTwoClustersTunnel creates two teleport clusters: "a" and "b" and creates a
Expand Down
6 changes: 5 additions & 1 deletion lib/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,11 @@ func NewNodeClient(ctx context.Context, sshConfig *ssh.ClientConfig, conn net.Co
"target_host", nodeName,
"error", err,
)
return nil, trace.AccessDenied("access denied to %v connecting to %v", sshConfig.User, nodeName)
host := nodeName
if h, _, err := net.SplitHostPort(nodeName); err == nil {
host = h
}
return nil, trace.AccessDenied("access denied to %v connecting to %v", sshConfig.User, host)
}
return nil, trace.Wrap(err)
}
Expand Down
3 changes: 1 addition & 2 deletions lib/proxy/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package proxy
import (
"bytes"
"context"
"errors"
"log/slog"
"math/rand/v2"
"net"
Expand Down Expand Up @@ -582,7 +581,7 @@ func getServerWithResolver(ctx context.Context, host, port string, cluster clust
return nil, trace.NotFound("unable to locate node matching %s-like target %s", idType, host)
}

return nil, trace.ConnectionProblem(errors.New("connection problem"), "direct dialing to nodes not found in inventory is not supported")
return nil, trace.ConnectionProblem(nil, "target host %s is offline or does not exist", host)
}
}

Expand Down
8 changes: 4 additions & 4 deletions lib/srv/transport/transportv1/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,19 +271,19 @@ func (s *Service) ProxySSH(stream transportv1pb.TransportService_ProxySSHServer)
// create a reader/writer for SSH Agent protocol
agentStreamRW, err := streamutils.NewReadWriter(agentStream)
if err != nil {
return trace.Wrap(err, "failed constructing ssh agent streamer")
return trace.Wrap(err, "creating ssh agent stream")
}
defer agentStreamRW.Close()

// create a reader/writer for SSH protocol
sshStreamRW, err := streamutils.NewReadWriter(sshStream)
if err != nil {
return trace.Wrap(err, "failed constructing ssh streamer")
return trace.Wrap(err, "creating ssh stream")
}

clientDst, err := getDestinationAddress(p.Addr, s.cfg.LocalAddr)
if err != nil {
return trace.Wrap(err, "could get not client destination address; listener address %q, client source address %q", s.cfg.LocalAddr.String(), p.Addr.String())
return trace.Wrap(err, "retrieving destination address; listener address %q, client source address %q", s.cfg.LocalAddr.String(), p.Addr.String())
}

signer := s.cfg.SignerFn(authzContext, req.DialTarget.Cluster)
Expand All @@ -293,7 +293,7 @@ func (s *Service) ProxySSH(stream transportv1pb.TransportService_ProxySSHServer)
if errors.Is(err, teleport.ErrNodeIsAmbiguous) {
return trace.Wrap(err)
}
return trace.Wrap(err, "failed to dial target host")
return trace.Wrap(err)
}

// ensure the connection to the target host
Expand Down
6 changes: 3 additions & 3 deletions lib/web/apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6816,7 +6816,7 @@ func TestDiagnoseSSHConnection(t *testing.T) {
Type: types.ConnectionDiagnosticTrace_CONNECTIVITY,
Status: types.ConnectionDiagnosticTrace_FAILED,
Details: `Failed to connect to the Node. Ensure teleport service is running using "systemctl status teleport".`,
Error: "direct dialing to nodes not found in inventory is not supported",
Error: "target host notanode is offline or does not exist",
},
},
},
Expand All @@ -6834,7 +6834,7 @@ func TestDiagnoseSSHConnection(t *testing.T) {
Type: types.ConnectionDiagnosticTrace_CONNECTIVITY,
Status: types.ConnectionDiagnosticTrace_FAILED,
Details: `Failed to connect to the Node. Ensure teleport service is running using "launchctl print 'system/Teleport Service'".`,
Error: "direct dialing to nodes not found in inventory is not supported",
Error: "target host notanode is offline or does not exist",
},
},
},
Expand All @@ -6853,7 +6853,7 @@ func TestDiagnoseSSHConnection(t *testing.T) {
Type: types.ConnectionDiagnosticTrace_CONNECTIVITY,
Status: types.ConnectionDiagnosticTrace_FAILED,
Details: `Open the Connect My Computer tab in Teleport Connect and make sure that the agent is running.`,
Error: "direct dialing to nodes not found in inventory is not supported",
Error: "target host notanode is offline or does not exist",
},
},
},
Expand Down
Loading