Skip to content
Open
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
2 changes: 2 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ type SftpConfiguration struct {
Port int `default:"2022" json:"bind_port" yaml:"bind_port"`
// If set to true, no write actions will be allowed on the SFTP server.
ReadOnly bool `default:"false" yaml:"read_only"`
// If set to true users won't be able to login using their password.
KeyOnly bool `default:"false" yaml:"key_only"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we not in some way sync this from the panel?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since read_only worked this way i thought about making the panel sync config when changing the setting there not making a request once wings start but that could be better

}

// ApiConfiguration defines the configuration for the internal API that is
Expand Down
6 changes: 6 additions & 0 deletions remote/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,9 @@ type SftpInvalidCredentialsError struct{}
func (ice SftpInvalidCredentialsError) Error() string {
return "the credentials provided were invalid"
}

type SftpKeyOnlyError struct{}

func (ice SftpKeyOnlyError) Error() string {
return "password authentication is disabled; only SSH keys are allowed"
}
5 changes: 5 additions & 0 deletions sftp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ func (c *SFTPServer) makeCredentialsRequest(conn ssh.ConnMetadata, t remote.Sftp
return nil, &remote.SftpInvalidCredentialsError{}
}

if t == remote.SftpAuthPassword && config.Get().System.Sftp.KeyOnly {
logger.Warn("failed to validate user credentials (password authentication is disabled; only SSH keys are allowed)")
return nil, &remote.SftpKeyOnlyError{}
}

resp, err := c.manager.Client().ValidateSftpCredentials(context.Background(), request)
if err != nil {
if _, ok := err.(*remote.SftpInvalidCredentialsError); ok {
Expand Down
Loading