How to connect to a Windows PC from a Mac OS X terminal

(Side note: If “ssh asdfasdf” says “Connection refused” rather than some variant of “unknown hostname”, then your ISP is doing the mildly nasty thing of “DNS redirection” which is intended to serve you a search page (to their profit) when you mistype a URL. This means they are running non-standards-compliant nameservers and software you run (that isn't a web browser) may be confused by it.)


For mounting network filesystems from the command line, the first thing you need to do is get the full URL. To do that, once you've got it up in the Finder, Get Info and look at the “Server:” field.

Then, to reproduce that in the Terminal, run open with that URL:

open smb://computer_name/share_name

You will get a dialog box requesting your credentials. Or, you can include your username and then you won't be prompted, provided that your password is in your Keychain:

open smb://your_username_on_that_computer@computer_name/share_name

(Apple file sharing is just the same, but with afp: instead of smb:.)

If you really need to do it with no GUI, you'll have to (as far as I know) do the mount directly (which requires you to manually specify its location in the filesystem by creating an empty directory). Here's an already-written answer: How can I easily mount a Windows share from my Mac?