Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When mounting a Samba share the user name is defaulting to the user name from the client machine rather than the "User Name" field from the earlier "Connect to Server" dialogue.

Accessing a Samba share over ssh from Linux with Nautilus where the client user name is "lfm" and the user name on the server system is "lastfirstmiddle":

$ who | awk '{print $1}'
lfm
lfm
$ sudo ssh lastfirstmiddle@example.com -L 445:samba.example.com:445 -L 139:samba.example.com:139 -f -N
[sudo] password for lfm: 
lastfirstmiddle@example.com's password:
$ nautilus

The user home share does not exhibit the problem. The password dialog is using the user name as specified in the "Connect to Server" dialogue as expected:

lfm - File Brower
Location: [/home/lfm]
File>Connect To Server...>

Connect To Server
Service type: [Windows Share]
Server: [localhost]
Share: [lastfirstmiddle]
User Name: [lastfirstmiddle]
Domain Name: [example-com]
<Connect>

Password required for share lastfirstmiddle on localhost
[x]Forget password immediately
Password: [*******]
<Connect>

lastfirstmiddle on localhost - File Browser
Location: [smb://example-com;lastfirstmiddle@localhost/lastfirstmiddle/]

Using the "Connect to Server" dialogue one can get a list of "Windows Shares" by leaving the "Share" field blank.

lastfirstmiddle on localhost - File Browser
File>Connect To Server...>

Connect To Server
Service type: [Windows Share]
Server: [localhost]
Share: []
User Name: [lastfirstmiddle]
Domain Name: [example-com]
<Connect>

Password required for share lastfirstmiddle on localhost
[x]Forget password immediately
Password: [*******]
<Connect>

On localhost - File Brower
Location: [smb://localhost/]

Then select a share and "Open with Open Folder" produces the "Connect to Server" dialog which unlike the previous case defaults the "User name" to the user on the client system. It does not pick up the value used in the "Connect to Server" dialogue that produced the list of shares.

On localhost - File Brower
Location: [smb://localhost/]
----------- ---- ----    -----
Name        Size Type    Date
----------- ---- ----    -----
AShare      --   Folder Unkown
BShare      --   Folder Unkown
CShare      --   Folder Unkown
{{XShare    --   Folder Unkown}}
YShare      --   Folder Unkown
ZShare      --   Folder Unkown
File>Open with Open Folder>

One can use "Connect to Server" and specify a "Bookmark" which can be used later to mount a share without having to compete the "Connect to Server" dialog each time. To have access to all six shares listed above (ABCXYZ) one would need to create six bookmarks. This might be OK for six shares but if there are dozens of shares this would be a bit obnoxious.

Is there a way to change the default user name to something other than the client system's user name?

share|improve this question

migrated from serverfault.com Feb 13 '11 at 6:06

This question came from our site for professional system and network administrators.

1  
Any luck getting it to work? –  penguin359 Apr 21 '11 at 0:48
add comment

1 Answer 1

You might be using share-level security (security = share) in your smb.conf file. In share-level security, Samba uses the share name as the username for the connection and does not ask for a username in the protocol. This is basically how Window 98 worked. You probably want security = user and you will need a proper smbpasswd file as well as Samba can't use the normal UNIX password database (/etc/passwd or /etc/shadow). Use smbpasswd -a lfm to add a new user for lfm and set it's password, set security = user in smb.conf and restart Samba.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.