How to connect to a Windows PC from a Mac OS X terminal
I have some Windows PCs on my network. I have Mac OS X. I try to access some Windows PCs in the network to read and write files. In OS X Finder, I see the computer_name and I can connect as Guest. But in the terminal, how can I do that?
I tried ssh computer_name
, but it says "connection refused". I tried ssh asdfasdf
(a computer_name that does not exist) and it gives me the same "connection refused". The leads me to suspect ssh computer_name
is not the right command to access a computer, which I found on the SU answer and google.
(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?
As for the answer to the question, if my memory serves me the syntax is
mount_smbfs //whoami@SERVER/share/ /SERVER/share
SERVER can just be a computer as well, it would be any computer share, not necessarily a SERVER.
whoami is the username of the user you want to connect to the server with, you can't just connect to any old folder share on a windows box without the computer knowing its okay for you to do so.
If you are using this format, you'll have to create the folder /SERVER/share on your hard drive, it represents the full path, so the mount point has a place to go. Once the command is executed, that folder then becomes pointed at the share for that session and can be browsed through gui or terminal.