Using SMBCLIENT to transfer files.

This information is gathered from a few different sources. I have it here for reference:

Step 1:
Create a file that contains authentication details. In my test case I had no domain to bother with so just added the username and password fields.

I also made a point of ensuring that the file permissions for this file were set to the owner having access only. Ie: rw- --- --- or ( 600 )

Thanks to: http://www.javascriptkit.com/script/script2/chmodcal.shtml for the very useful chmod calculator.

smbclient_authentication.txt
username = backupuser
password = Pa$$w0rd

Step 2:
In your script or whatever the way to put a file onto the windows share is like this:

~> smbclient -A smbclient_authentication.txt ////192.168.0.96//data -c "put myBackupFile.tar.gz"
That's about it. Piece of cake. When I test this on an SELINUX environment, I am sure this tutorial will be extended somewhat!

Comments

Anonymous said…
Thanks - works great. It still asks for file copy confirmation, so I had to add this to my script -

echo y | smbclient -A ~/auth.txt //192.168.1.160/backups/ -c "mput backup.zip"
ElGreco said…
y can use prompt; instead

Popular posts from this blog

Automatically mount NVME volumes in AWS EC2 on Windows with Cloudformation and Powershell Userdata

Extending the AD Schema on Samba4 - Part 2

Extending the AD Schema on Samba4 - Part 1