In case of non-operational AWS Console access using "tsh aws" results in confusing error message. Instead of XML with information we return HTTP 302 redirect, which the AWS CLI doesn't know how to handle. See #10789 for how to make the faulty setup which results in this.
What you expected to happen:
A meaningful error. Obtaining web session has failed, this should be caught by Teleport proxy handling the connection and reported as such.
Reproduction Steps
See #10789 for detailed setup steps. This is the same scenario, except using "tsh aws" command.
Server Details
Teleport version: v9 beta
Client Details
Tsh version: v9 beta
Debug Logs
Teleport logs. Note that these mix the original cause of failure (inability to create reverse tunnel from node to itself - dial tcp timeout) and the resulting failure to create the app session (which ultimately results in confusing redirect to /web).
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: 2022-03-03T14:48:03Z DEBU [APP:SERVI] Dial to tele-1.aws.tener.io:3080 failed. error:[
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: ERROR REPORT:
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: Original Error: *net.OpError dial tcp 3.66.85.216:3080: i/o timeout
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: Stack Trace:
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/utils/proxy/proxy.go:129 github.com/gravitational/teleport/lib/utils/proxy.directDial.DialTimeout
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/reversetunnel/agent.go:292 github.com/gravitational/teleport/lib/reversetunnel.(*Agent).connect
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/reversetunnel/agent.go:385 github.com/gravitational/teleport/lib/reversetunnel.(*Agent).run
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /opt/go/src/runtime/asm_amd64.s:1581 runtime.goexit
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: User Message: dial tcp 3.66.85.216:3080: i/o timeout] leaseID:94 target:tele-1.aws.tener.io:3080 reversetunnel/agent.go:294
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: 2022-03-03T14:48:03Z WARN [APP:SERVI] Failed to create remote tunnel: failed to dial: all auth methods failed, conn: <nil>. leaseID:94 target:tele-1.aws.tener.io:3080 reversetunnel/agent.go:387
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: 2022-03-03T14:48:03Z DEBU [APP:SERVI] Changing state connecting -> disconnected. leaseID:94 target:tele-1.aws.tener.io:3080 reversetunnel/agent.go:208
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: 2022-03-03T14:48:03Z DEBU [PROXY:AGE] Adding agent(leaseID=95,state=connecting) -> main:tele-1.aws.tener.io:3080. cluster:main reversetunnel/agentpool.go:308
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: 2022-03-03T14:48:03Z DEBU [HTTP:PROX] No valid environment variables found. proxy/proxy.go:337
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: 2022-03-03T14:48:03Z DEBU [HTTP:PROX] No proxy set in environment, returning direct dialer. proxy/proxy.go:244
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: 2022-03-03T14:48:03Z DEBU [APP:SERVI] Pool is closing agent. leaseID:94 target:tele-1.aws.tener.io:3080 reversetunnel/agentpool.go:238
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: 2022-03-03T14:48:03Z DEBU [AUTH] ClientCertPool -> cert(main issued by main:84549874656568164947356731045716606294) auth/middleware.go:609
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: 2022-03-03T14:48:03Z DEBU [AUTH] ClientCertPool -> cert(main issued by main:62115784750887467050448464695030025758) auth/middleware.go:609
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: 2022-03-03T14:48:03Z DEBU [PROXY:SER] Dialing from: "@web-proxy" to: "@local-node". trace.fields:map[cluster:main] reversetunnel/localsite.go:198
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: 2022-03-03T14:48:03Z DEBU [PROXY:SER] Error occurred while dialing through a tunnel. address:@local-node error:[
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: ERROR REPORT:
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: Original Error: *trace.NotFoundError no tunnel connection found: no app reverse tunnel for 638f1d8b-bd06-4252-a498-644b1ed28fe1.main found
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: Stack Trace:
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/reversetunnel/localsite.go:279 github.com/gravitational/teleport/lib/reversetunnel.(*localSite).dialTunnel
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/reversetunnel/localsite.go:303 github.com/gravitational/teleport/lib/reversetunnel.(*localSite).getConn
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/reversetunnel/localsite.go:200 github.com/gravitational/teleport/lib/reversetunnel.(*localSite).DialTCP
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/reversetunnel/localsite.go:193 github.com/gravitational/teleport/lib/reversetunnel.(*localSite).Dial
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/web/app/transport.go:238 github.com/gravitational/teleport/lib/web/app.dialAppServer
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/web/app/match.go:88 github.com/gravitational/teleport/lib/web/app.MatchHealthy.func1
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/web/app/match.go:97 github.com/gravitational/teleport/lib/web/app.MatchAll.func1
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/web/app/match.go:54 github.com/gravitational/teleport/lib/web/app.Match
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/web/app/session.go:72 github.com/gravitational/teleport/lib/web/app.(*Handler).newSession
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/web/app/handler.go:263 github.com/gravitational/teleport/lib/web/app.(*Handler).getSession
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/web/app/handler.go:177 github.com/gravitational/teleport/lib/web/app.(*Handler).authenticate
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/web/app/middleware.go:50 github.com/gravitational/teleport/lib/web/app.(*Handler).withAuth.func1
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/web/app/middleware.go:124 github.com/gravitational/teleport/lib/web/app.makeHandler.func1
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /opt/go/src/net/http/server.go:2046 net/http.HandlerFunc.ServeHTTP
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /tmp/gomodcache/github.com/julienschmidt/httprouter@v1.3.0/router.go:448 github.com/julienschmidt/httprouter.(*Router).ServeHTTP
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/web/app/handler.go:135 github.com/gravitational/teleport/lib/web/app.(*Handler).ServeHTTP
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/web/apiserver.go:207 github.com/gravitational/teleport/lib/web.(*APIHandler).ServeHTTP
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /tmp/gomodcache/github.com/gravitational/oxy@v0.0.0-20211213172937-a1ba0900a4c9/ratelimit/tokenlimiter.go:118 github.com/gravitational/oxy/ratelimit.(*TokenLimiter).ServeHTTP
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /tmp/gomodcache/github.com/gravitational/oxy@v0.0.0-20211213172937-a1ba0900a4c9/connlimit/connlimit.go:75 github.com/gravitational/oxy/connlimit.(*ConnLimiter).ServeHTTP
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /opt/go/src/net/http/server.go:2878 net/http.serverHandler.ServeHTTP
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /opt/go/src/net/http/server.go:1929 net/http.(*conn).serve
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /opt/go/src/runtime/asm_amd64.s:1581 runtime.goexit
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: User Message: no tunnel connection found: no app reverse tunnel for 638f1d8b-bd06-4252-a498-644b1ed28fe1.main found] trace.fields:map[cluster:main] reversetunnel/localsite.go:312
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: 2022-03-03T14:48:03Z DEBU [PROXY:SER] Dialing from: "@web-proxy" to: "@local-node". trace.fields:map[cluster:main] reversetunnel/localsite.go:198
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: 2022-03-03T14:48:03Z DEBU [PROXY:SER] Error occurred while dialing through a tunnel. address:@local-node error:[
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: ERROR REPORT:
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: Original Error: *trace.NotFoundError no tunnel connection found: no app reverse tunnel for 638f1d8b-bd06-4252-a498-644b1ed28fe1.main found
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: Stack Trace:
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/reversetunnel/localsite.go:279 github.com/gravitational/teleport/lib/reversetunnel.(*localSite).dialTunnel
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/reversetunnel/localsite.go:303 github.com/gravitational/teleport/lib/reversetunnel.(*localSite).getConn
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/reversetunnel/localsite.go:200 github.com/gravitational/teleport/lib/reversetunnel.(*localSite).DialTCP
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/reversetunnel/localsite.go:193 github.com/gravitational/teleport/lib/reversetunnel.(*localSite).Dial
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/web/app/transport.go:238 github.com/gravitational/teleport/lib/web/app.dialAppServer
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/web/app/match.go:88 github.com/gravitational/teleport/lib/web/app.MatchHealthy.func1
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/web/app/match.go:97 github.com/gravitational/teleport/lib/web/app.MatchAll.func1
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/web/app/match.go:54 github.com/gravitational/teleport/lib/web/app.Match
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/web/app/session.go:72 github.com/gravitational/teleport/lib/web/app.(*Handler).newSession
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/web/app/handler.go:263 github.com/gravitational/teleport/lib/web/app.(*Handler).getSession
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/web/app/handler.go:177 github.com/gravitational/teleport/lib/web/app.(*Handler).authenticate
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/web/app/middleware.go:50 github.com/gravitational/teleport/lib/web/app.(*Handler).withAuth.func1
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/web/app/middleware.go:124 github.com/gravitational/teleport/lib/web/app.makeHandler.func1
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /opt/go/src/net/http/server.go:2046 net/http.HandlerFunc.ServeHTTP
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /tmp/gomodcache/github.com/julienschmidt/httprouter@v1.3.0/router.go:448 github.com/julienschmidt/httprouter.(*Router).ServeHTTP
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/web/app/handler.go:135 github.com/gravitational/teleport/lib/web/app.(*Handler).ServeHTTP
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /go/src/github.com/gravitational/teleport/lib/web/apiserver.go:207 github.com/gravitational/teleport/lib/web.(*APIHandler).ServeHTTP
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /tmp/gomodcache/github.com/gravitational/oxy@v0.0.0-20211213172937-a1ba0900a4c9/ratelimit/tokenlimiter.go:118 github.com/gravitational/oxy/ratelimit.(*TokenLimiter).ServeHTTP
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /tmp/gomodcache/github.com/gravitational/oxy@v0.0.0-20211213172937-a1ba0900a4c9/connlimit/connlimit.go:75 github.com/gravitational/oxy/connlimit.(*ConnLimiter).ServeHTTP
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /opt/go/src/net/http/server.go:2878 net/http.serverHandler.ServeHTTP
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /opt/go/src/net/http/server.go:1929 net/http.(*conn).serve
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: /opt/go/src/runtime/asm_amd64.s:1581 runtime.goexit
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: User Message: no tunnel connection found: no app reverse tunnel for 638f1d8b-bd06-4252-a498-644b1ed28fe1.main found] trace.fields:map[cluster:main] reversetunnel/localsite.go:312
Mar 03 14:48:03 ip-172-31-27-191.eu-central-1.compute.internal teleport[30590]: 2022-03-03T14:48:03Z WARN [APP:WEB] Failed to get session: failed to match applications. app/handler.go:179
tsh logs. Notice double --debug flag: one applies to tsh, one to aws.
Description
What happened:
In case of non-operational AWS Console access using "tsh aws" results in confusing error message. Instead of XML with information we return HTTP 302 redirect, which the AWS CLI doesn't know how to handle. See #10789 for how to make the faulty setup which results in this.
What you expected to happen:
A meaningful error. Obtaining web session has failed, this should be caught by Teleport proxy handling the connection and reported as such.
Reproduction Steps
See #10789 for detailed setup steps. This is the same scenario, except using "tsh aws" command.
Server Details
Client Details
Debug Logs
Teleport logs. Note that these mix the original cause of failure (inability to create reverse tunnel from node to itself - dial tcp timeout) and the resulting failure to create the app session (which ultimately results in confusing redirect to
/web
).tsh
logs. Notice double--debug
flag: one applies totsh
, one toaws
.