diff --git a/cmd/configs/config_template.yaml b/cmd/configs/config_template.yaml index d2b5ab8b..45c7c48a 100644 --- a/cmd/configs/config_template.yaml +++ b/cmd/configs/config_template.yaml @@ -79,8 +79,10 @@ sshd: # OPTIONAL: if true, the sftp subsystem will be disabled server side disable_sftp_subsystem: false # OPTIONAL: if empty a shell will be auto inferred. You can - # set a custom value here. Example: /usr/bin/python3 - shell_executable: "your/custom/shell/fullpath" + # set a custom value here. + # Example1: /usr/bin/python3 + # Example2: sh -c your command here + shell_executable: "your/custom/shell" # enables and configures rest endpoints and web ui # Be WARNED: the endpoint is not authenticated and through the apis diff --git a/pkg/sshd/server.go b/pkg/sshd/server.go index 5fe629b0..2711df66 100644 --- a/pkg/sshd/server.go +++ b/pkg/sshd/server.go @@ -6,7 +6,6 @@ import ( "net" "net/http" "net/url" - "os" "runtime" "strconv" "strings" @@ -74,12 +73,6 @@ func NewSshServer(conf *SshDConf) *sshServer { panic(err) } - if conf.ShellExecutable != "" { - if _, err := os.Stat(conf.ShellExecutable); err != nil { - log.Fatalf("invalid shell executable '%s'", conf.ShellExecutable) - } - } - ss := &sshServer{ authorizedKeysURI: conf.AuthorizedKeysURI, password: conf.AuthorizedPassword, diff --git a/pkg/sshd/session_chan_handler.go b/pkg/sshd/session_chan_handler.go index a7fa458e..efaa1531 100644 --- a/pkg/sshd/session_chan_handler.go +++ b/pkg/sshd/session_chan_handler.go @@ -7,6 +7,7 @@ import ( "os" "os/exec" "os/user" + "strings" "sync" "github.com/ferama/rospo/pkg/rpty" @@ -81,7 +82,12 @@ func handleChannelSession( var cmd *exec.Cmd if req.Type == "shell" { - cmd = exec.Command(shell) + if customShell != "" { + parts := strings.Split(customShell, " ") + cmd = exec.Command(parts[0], parts[1:]...) + } else { + cmd = exec.Command(shell) + } } else { var payload = struct{ Value string }{} ssh.Unmarshal(req.Payload, &payload)