Skip to content

Samba

Samba is the unix SMB daemon of choice.

Commands

/usr/bin/net

Samba has a generically named binary file called net, which matches the windows command. It's used to manage Samba and CIFS servers.

testparm

testparm - check an smb.conf configuration file for internal correctness. This is great for having a heavily commented main file, like smb.conf.master, then generating the bare smb.conf from that file using testparm -s smb.conf.master > smb.conf.

smbtree

The smbtree tool will print out a tree list of all the reachable samba shares.

Tips

get info from winbind

wbinfo

Clear name resolution cache

net cache flush

Get a remote rpc shell

net rpc shell -U $user_name -S $host_name

Show open sessions on local server

net status shares

Show open files on remote server

net rpc file -S $server_name

Mount a samba share on a linux client

mount -t smbfs -o username=$user_name //$server_name/C$ $local_share_name

Mount a remote share

mount_smbfs "//domain_name;username@hostname/groups" asdf

Kill all Samba sessions for a given user, hence forcing refresh of their group memberships

net status sessions | grep johndoe | awk '{print $1}' | xargs sudo kill

Join domain in ads security mode

net ads join -U dhoherd@DOMAIN.EXAMPLE.COM

Leave domain:

net ads leave -U dhoherd@DOMAIN.EXAMPLE.COM

Upgrading Supermicro firmware

Supermicro iKVM can only mount ISOs that are hosted on Samba shares... 🙄 In my experience they also only support the old and vulnerable SMBv1 protocol. (wannacry used SMBv1.) In order to host ISOs for use with iKVM, it's useful to run Samba in Docker so it is isolated and only running while you are using it.

This example uses the docker image dperson/samba to start a Samba server sharing one passwordless /public share which mounts $HOME/isos from outside the container.

docker run \
  --name "$USER-samba" \
  --rm \
  -d \
  -p 139:139 \
  -p 445:445  \
  -v $HOME/isos:/public  \
  -d dperson/samba \
  -s "public;/public" \
  -g "server min protocol = NT1" \
  -g "log level = 3"