Skip to content

The configuration editor drops SMB usernames when they are equal to the username of the user, making usage of the same in systemd more difficult #9356

Closed

Description

@electric-sheepgirl

The associated forum post URL from https://forum.rclone.org

n/a

What is your current rclone version (output from rclone version)?

rclone v1.73.4
- os/version: cachyos (64 bit)
- os/kernel: 6.19.12-1-cachyos (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.26.2-X:nodwarf5
- go/linking: dynamic
- go/tags: none

What problem are you are trying to solve?

When creating a remote of type smb, the configuration editor will not output the provided SMB username to the configuration file if it happens to be equal to that of the running user. Presumably, the rationale for this is that rclone can and will look up the username of the running user at remote usage time if one is not present in the configuration file. However, this makes it difficult to create systemd mount configurations for the same. systemd mount configurations will run as root. rclone will therefore send the username root to the SMB server, which will cause an authentication failure.

My current workaround is to manually edit the configuration file printed by $ rclone config file to include an explicit user = $MYUSERNAME line in the section for my SMB remote.

How do you think rclone should be changed to solve that?

In descending order of preference:

  1. rclone should always output the SMB username to the configuration file, even if it happens to equal the username of the local account creating the configuration file. This makes configuration files containing SMB remotes more portable at the cost of a marginal increase in configuration file size for users who happen to have local usernames equal to their SMB usernames.
  2. rclone could output an SMB username that is equal to the username of the local account creating the configuration only if the full username is explicitly specified by the user. When the user simply hits Enter on the username prompt in the configuration editor, rclone could continue to elide the SMB username from the configuration file and look it up at remote usage time. This would prevent increases to the configuration file size for users that have a local username matching their SMB username while providing an escape hatch for users that have a local username matching their SMB username and who wish to create systemd mount configurations for their SMB remotes, but is more confusing in the general case.
  3. The rclone docs for the smb share type could be updated to note this edge case, and warn users about the danger.

In any scenario, it's probably best to keep the behavior of looking up the username at remote usage time to avoid breaking existing users with an smb remote configured that does not contain an SMB username.

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Activity

  1. ncw commented on Apr 19, 2026

    @ncw
    Member

    This is quite deeply embedded into the rclone config system. Namely rclone doesn't write the defaults into the config file. Since the default is set to the current user, it never gets written to the config file.

    We can't change that mechanism without breaking stuff and we can't change the default user for the smb backend without breaking existing configs.

    Can't think of a sensible fix other than documenting the problem.

    Any ideas?

  2. ncw commented on Apr 20, 2026

    @ncw
    Member

    Ok here is an idea

    • change the default to ""
    • when we use it, resolve that to the current user if it is ""

    That would be backwards compatible and allow you to chose your username explicitly.

    How does that sound?

    I note that there are other backends which could use this fix like sftp and probably others

  3. electric-sheepgirl commented on Apr 20, 2026

    @electric-sheepgirl
    Author

    We can't change that mechanism without breaking stuff and we can't change the default user for the smb backend without breaking existing configs.

    That makes sense, but is it possible (and simpler) to change that mechanism for just this parameter? Something like:

    1. Add a parameter to the Option struct named something like persistDefault
    2. Set the parameter to true for the user param in the smb backend
    3. Change whatever existing logic looks like if (/* option is not set to default */) { /* write option */} to if (/* option is not set to default OR persist default values for this option */) { /* write option */ } (I tried to find where this logic lives, but failed)

    If that's not possible, or if doing that would be a less simple fix, the proposed fix in #9356 (comment) also sounds reasonable to me.

    I note that there are other backends which could use this fix like sftp and probably others

    Yeah, it looks like the ftp and sftp backends also use the env.currentUser function and might also benefit from a fix.

  4. added 2 commits that reference this issue on Sep 19, 2026
    4c4d4e8
    972d600
  5. ncw commented on Sep 21, 2026

    @ncw
    Member

    I've merged @hsdfat fix for this this to master now which means it will be in the latest beta in 15-30 minutes and released in v1.76

  6. added a commit that references this issue on Sep 21, 2026
    3c51b96
  7. added a commit that references this issue on Oct 6, 2026
    cccd83c
  8. added a commit that references this issue on Oct 8, 2026
    5ea1851
  9. added a commit that references this issue on Nov 21, 2026
    aab2bfa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions