smbclientAfter you know the shares available on a Samba server, you can log in and start using them. Use the smbclient command, but in this format: smbclient //server/share -U username You can't just log in to a server; instead, you need to log in to a share on that server. To access password-protected items (and it's certainly advisable to password-protect your shares), you need to specify a user. To access the documents share on the server ELIOT, you'd use the following: $ smbclient //eliot/documents -U scott Password: Domain=[ELIOT] OS=[Unix] Server=[Samba 3.0.14a- Ubuntu] smb: \> You'll know you were successful because you'll be at the Samba prompt, which looks like smb: \>. Notice that you're prompted for a password. Assuming that the password for the scott user was 123456 (a very bad password, but this is just hypothetical), you could have entered this command instead, and you wouldn't be prompted for a password: $ smbclient //eliot/documents -U scott%123456 This is a terrible idea, however, because anyone looking at either your .bash_history file (discussed in the "View Your Command-Line History" section in Chapter 11, "Your Shell") or the list of running processes with ps (see "View All Currently Running Processes" in Chapter 12, "Monitoring System Resources") could see your password. Never append your password onto your username. It's just good security practice to enter it when prompted. Tip If you're writing a script and you need to log in without interaction, you still shouldn't append the password onto the username. Instead, use the -A (or --authentication-file=[filename]) option, which references a credentials file. Using the scott user, that file would contain the following: username = scott password = 123456 Make sure you use chmod (see Chapter 7, "Ownerships and Permissions") to set the permissions on that file so it isn't readable by the world. After you're connected to a Samba share, you can use many of the commands familiar to those who have ever used FTP on the command line (see Table 16.1).
You can view other commands by simply typing help after you've logged in to the Samba server, but Table 16.1 contains the basics. When you're finished, simply type exit, and you log out of the server and are back on your own machine. |