Next Previous Contents

8. Scripting file transfer using smbclient over SSH

It is also possible to specify the password on the command line when using smbclient by separating it with a % character from the username in the -U argument - this coupled with the smbclient argument -c can be useful for scripting purposes as the -c argument allows you to pass a command to smbclient to be run after login. - Here are some examples

Example 1 - upload foobar.tar.gz from the current directory to the remote windows share over the ssh tunnel.

smbclient //windows_server_NETBIOS_NAME/destination_folder -U WINDOWS_USER%WINDOWS_PASSWORD -I 127.0.0.1 -c "put foobar.tar.gz"

Example 2 - download some_file.tar.bz2 from the remote share to the current local directory.

smbclient //windows_server_NETBIOS_NAME/destination_folder -U WINDOWS_USER%WINDOWS_PASSWORD -I 127.0.0.1 -c "get some_file.tar.bz2"

Example 3 - get a directory listing of the destination_folder

smbclient //windows_server_NETBIOS_NAME/destination_folder -U WINDOWS_USER%WINDOWS_PASSWORD -I 127.0.0.1 -c "ls"


Next Previous Contents