diff --git a/cmd/agent/agent.go b/cmd/agent/agent.go index 20d03b5..0332db1 100755 --- a/cmd/agent/agent.go +++ b/cmd/agent/agent.go @@ -300,7 +300,7 @@ func main() { defer wsConn.Close() shell := chooseShell(shells) - serverInfo, err := comms.AgentInitialization(wsConn, comms.NewAgentInfo(shell)) + _, err = comms.AgentInitialization(wsConn, comms.NewAgentInfo(shell)) if err != nil { log.Printf("ERROR: %v", err) os.Exit(1) @@ -352,10 +352,10 @@ func main() { log.Println() log.Printf("Clients should use the following commands to connect to this agent:") log.Println() - sshCommand := fmt.Sprintf("ssh -oServerAliveInterval=10 -oProxyCommand=\"wsproxy %s\" %s@localhost", - clientUrl, serverInfo.UserPassword.Username) - sftpCommand := fmt.Sprintf("sftp -oServerAliveInterval=10 -oProxyCommand=\"wsproxy %s\" %s@localhost", - clientUrl, serverInfo.UserPassword.Username) + sshCommand := fmt.Sprintf("ssh -oServerAliveInterval=10 -oProxyCommand=\"wsproxy %s\" localhost", + clientUrl) + sftpCommand := fmt.Sprintf("sftp -oServerAliveInterval=10 -oProxyCommand=\"wsproxy %s\" localhost", + clientUrl) log.Println(" # For SSH") log.Println(" " + sshCommand) log.Println() diff --git a/cmd/converge/converge.go b/cmd/converge/converge.go index ee3aff9..0d73952 100644 --- a/cmd/converge/converge.go +++ b/cmd/converge/converge.go @@ -1,19 +1,16 @@ package main import ( - "converge/pkg/comms" "converge/pkg/models" "converge/pkg/server/converge" "converge/pkg/support/websocketutil" "fmt" "log" - "math/rand" "net" "net/http" _ "net/http/pprof" "os" "regexp" - "strconv" "strings" _ "time/tzdata" ) @@ -98,19 +95,6 @@ func main() { printHelp("") } - userPassword := comms.UserPassword{ - Username: strconv.Itoa(rand.Int()), - } - - username, ok := os.LookupEnv("CONVERGE_USERNAME") - if ok { - userPassword.Username = username - } else { - os.Setenv("CONVERGE_USERNAME", userPassword.Username) - } - - log.Printf("Using username '%s'", userPassword.Username) - notifications := make(chan *models.State, 10) admin := converge.NewAdmin(notifications) websessions := converge.NewWebSessions(notifications) @@ -124,8 +108,7 @@ func main() { return } log.Printf("Got registration connection: '%s'\n", publicId) - err = admin.Register(publicId, conn, - userPassword) + err = admin.Register(publicId, conn) if err != nil { log.Printf("Error %v\n", err) } diff --git a/cmd/converge/convergeaccess.go b/cmd/converge/convergeaccess.go index 7a6227e..effea3a 100644 --- a/cmd/converge/convergeaccess.go +++ b/cmd/converge/convergeaccess.go @@ -8,7 +8,7 @@ import ( "strings" ) -func getConvergeAccess(r *http.Request, sshRemoteUser string) models.ConvergeAccess { +func getConvergeAccess(r *http.Request) models.ConvergeAccess { pattern := regexp.MustCompile("^(.*)/usage$") matches := pattern.FindStringSubmatch(r.URL.Path) @@ -41,6 +41,5 @@ func getConvergeAccess(r *http.Request, sshRemoteUser string) models.ConvergeAcc Secure: secure, BaseUrl: baseUrl, Location: location, - Username: sshRemoteUser, } } diff --git a/cmd/converge/pagehandler.go b/cmd/converge/pagehandler.go index bcc46d7..4494039 100644 --- a/cmd/converge/pagehandler.go +++ b/cmd/converge/pagehandler.go @@ -6,8 +6,7 @@ import ( ) func pageHandler(w http.ResponseWriter, r *http.Request) { - username := getAgentSshUser() - access := getConvergeAccess(r, username) + access := getConvergeAccess(r) switch r.URL.Path { case "": diff --git a/cmd/converge/usage.go b/cmd/converge/usage.go index 8e89759..419a594 100644 --- a/cmd/converge/usage.go +++ b/cmd/converge/usage.go @@ -6,7 +6,6 @@ import ( "github.com/gliderlabs/ssh" "math/rand" "net/http" - "os" "regexp" "strconv" "strings" @@ -37,7 +36,7 @@ func generateCLIExammple(w http.ResponseWriter, r *http.Request) { sshPublicKeys = append(sshPublicKeys, line) } } - access := getConvergeAccess(r, getAgentSshUser()) + access := getConvergeAccess(r) usageInputs := templates.NewUsageInputs(id, sshPublicKeys, remoteShells, localShells) matched, _ := regexp.MatchString("^[a-zA-Z0-9-_]+$", id) @@ -68,8 +67,3 @@ func generateCLIExammple(w http.ResponseWriter, r *http.Request) { http.Error(w, err.Error(), 500) } } - -func getAgentSshUser() string { - username, _ := os.LookupEnv("CONVERGE_USERNAME") - return username -} diff --git a/cmd/templaterender/render.go b/cmd/templaterender/render.go index a414ea7..a89e3b5 100644 --- a/cmd/templaterender/render.go +++ b/cmd/templaterender/render.go @@ -41,7 +41,6 @@ func main() { Secure: "s", BaseUrl: "example.com", Location: netherlands, - Username: "converge", } fullindex := func() templ.Component { diff --git a/compose.yaml b/compose.yaml index 8009cce..71ed4b8 100644 --- a/compose.yaml +++ b/compose.yaml @@ -7,6 +7,3 @@ services: context: . ports: - 8000:8000 - environment: - CONVERGE_USERNAME: abc - TZ: "Japan" diff --git a/kubernetes/deployment.yaml b/kubernetes/deployment.yaml index 52e2039..8f946f3 100644 --- a/kubernetes/deployment.yaml +++ b/kubernetes/deployment.yaml @@ -21,8 +21,5 @@ spec: name: converge ports: - containerPort: 8000 - env: - - name: CONVERGE_USERNAME - value: converge diff --git a/pkg/comms/events.go b/pkg/comms/events.go index f8c6653..c47fb70 100644 --- a/pkg/comms/events.go +++ b/pkg/comms/events.go @@ -47,14 +47,9 @@ type ProtocolVersion struct { Version int } -type UserPassword struct { - Username string -} - // initialization mesaage when agent connects to server type ServerInfo struct { - UserPassword UserPassword } // confirmation message when agent connects @@ -106,9 +101,6 @@ func RegisterEventsWithGob() { // ConvergeServer to Agent and client gob.Register(ProtocolVersion{}) - // ConvergeServer to Agent - gob.Register(UserPassword{}) - // ConvergeServer to Client gob.Register(ClientConnectionInfo{}) diff --git a/pkg/models/convergeaccess.go b/pkg/models/convergeaccess.go index 3c5e2d1..a812f86 100644 --- a/pkg/models/convergeaccess.go +++ b/pkg/models/convergeaccess.go @@ -7,5 +7,4 @@ type ConvergeAccess struct { Secure string BaseUrl string Location *time.Location - Username string } diff --git a/pkg/server/converge/admin.go b/pkg/server/converge/admin.go index 930ef02..a88e75d 100644 --- a/pkg/server/converge/admin.go +++ b/pkg/server/converge/admin.go @@ -266,12 +266,9 @@ func (admin *Admin) RemoveClient(client *ClientConnection) error { return nil } -func (admin *Admin) Register(publicId string, conn io.ReadWriteCloser, - userPassword comms.UserPassword) error { +func (admin *Admin) Register(publicId string, conn io.ReadWriteCloser) error { - serverInfo := comms.ServerInfo{ - UserPassword: userPassword, - } + serverInfo := comms.ServerInfo{} agentInfo, err := comms.ServerInitialization(conn, serverInfo) if err != nil { diff --git a/pkg/server/templates/usage.templ b/pkg/server/templates/usage.templ index 9cc3298..7a75626 100644 --- a/pkg/server/templates/usage.templ +++ b/pkg/server/templates/usage.templ @@ -54,17 +54,14 @@ templ AgentUsage(access models.ConvergeAccess, usageInputs UsageInputs) {
The embedded ssh server in the agent supports both ssh and sftp. The user name is fixed
- at { access.Username }
. This is the user used to connect to the embedded
- SSH server, after logging in however you will be running in a shell that is started
- by the same user that started the agent.
+
The embedded ssh server in the agent supports both ssh and sftp.
This requires the tcptows
utility which is available in the
downloads section. The utility must be started beforehand