-
-
Notifications
You must be signed in to change notification settings - Fork 576
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR fixes issues with the terminal when running netbird ssh to a remote agent. Every session looks up a user and loads its profile. If no user is found, the connection is rejected. The default user is root.
- Loading branch information
Showing
5 changed files
with
137 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package ssh | ||
|
||
import ( | ||
"fmt" | ||
"github.com/netbirdio/netbird/util" | ||
"net" | ||
"net/netip" | ||
"os/exec" | ||
"runtime" | ||
) | ||
|
||
func getLoginCmd(user string, remoteAddr net.Addr) (loginPath string, args []string, err error) { | ||
loginPath, err = exec.LookPath("login") | ||
if err != nil { | ||
return "", nil, err | ||
} | ||
|
||
addrPort, err := netip.ParseAddrPort(remoteAddr.String()) | ||
if err != nil { | ||
return "", nil, err | ||
} | ||
|
||
if runtime.GOOS == "linux" { | ||
|
||
if util.FileExists("/etc/arch-release") && !util.FileExists("/etc/pam.d/remote") { | ||
// detect if Arch Linux | ||
return loginPath, []string{"-f", user, "-p"}, nil | ||
} | ||
|
||
return loginPath, []string{"-f", user, "-h", addrPort.Addr().String(), "-p"}, nil | ||
} else if runtime.GOOS == "darwin" { | ||
return loginPath, []string{"-fp", "-h", addrPort.Addr().String(), user}, nil | ||
} | ||
|
||
return "", nil, fmt.Errorf("unsupported platform") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters