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

6

5

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.

KMC

Posted 2012-01-06T01:10:19.730

Reputation: 1 537

Windows 10 now includes both SSH client and server! Has for almost a year for preview builds (https://blogs.msdn.microsoft.com/commandline/2018/01/22/openssh-in-windows-10/), and the client portion is out of beta and enabled by default in the recent releases. For the server portion, still branded beta and disabled by default, you can also read this: https://www.bleepingcomputer.com/news/microsoft/how-to-install-the-built-in-windows-10-openssh-server/. (Obviously, neither of these solve the problem if the server wasn't enabled before-hand.)

– CBHacking – 2018-12-30T02:46:07.887

1Not an answer, but some information: ssh is a way to connect to computers that are running an ssh server. Most (if not all) UNIX-y systems (including OS X and Linux) can run ssh servers, and these can be easily turned on with built-in software. Desktop Windows does not (to my knowledge) come with an ssh server to turn on, though you (presumably) could get one and install it. (This is not an answer as I can neither point you to a Windows ssh server package nor do I know any alternative solutions.) – Cajunluke – 2012-01-06T01:22:20.243

Just as FYI. Syntax of ssh is 'ssh username@10.10.10.10'. – Paperlantern – 2012-01-06T02:29:04.197

but i only know the computer name, not IP information... – KMC – 2012-01-06T02:34:48.637

For ssh, you can use computer name as well, but again i was just building on his info, this doesn't answer your question, this is for ssh to other *nix machines, see below for my direct answer. – Paperlantern – 2012-01-06T03:00:58.670

Answers

3

(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?

Kevin Reid

Posted 2012-01-06T01:10:19.730

Reputation: 2 854

Ah, this works but just opens it in the gui, the way i read it, he wanted to be able to browse the contents once connected while still in terminal. This does get you to the share as well though. – Paperlantern – 2012-01-06T02:55:47.847

2Just cd /Volumes/share_name if it's already mounted. – Kevin Reid – 2012-01-06T02:58:15.147

1

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.

Paperlantern

Posted 2012-01-06T01:10:19.730

Reputation: 3 592

i do not understand your writing. What is "memory serves"? Is it related to the memory information of the computer? What is "mount_smbfs" is it a unix command? – KMC – 2012-01-06T02:36:05.410

I tried in terminal 'mount_smbfs // whoami @computer_name', it gives error "could not find". What is whoami and @SERVER? is it an IP? I do not have any IP. Only computer name. Between windows machine, I only need to type on run: \computer_name. – KMC – 2012-01-06T02:38:18.077

Yeah windows is friendlier to it's "kin" heh, windows speaks windows. OSX doesn't speak windows unless you tell it too, smbfs is the command to tell it to use the samba communication so to speak. Also, the second path, is where you want to mount it to, such as the folder SERVER and the folder SHARE in your home folder on your mac. – Paperlantern – 2012-01-06T02:45:31.013

Correction, it has been a while since I've done this through terminal, i usually just use the "Go" menu. the final /SERVER/Share bit represents the FULL path of the mount point, so if you created it in your home folder it would be /Users/yourusername/SERVER/Share – Paperlantern – 2012-01-06T02:54:12.913

0

Windows 10 now comes with a built-in OpenSSH server. But you will have to follow this post to ensure it gets installed via the Windows 10 "apps and features" screen (otherwise it will throw an error silently, only noticeable if you check the additional features history). You will probably have to reboot, and then you will see the new OpenSSH feature installed. Finally, go to services.msc and manually start the OpenSSH services.

Daniel Cañas

Posted 2012-01-06T01:10:19.730

Reputation: 1

0

Windows does not support SSH natively. You can install a program like Cygwin or MinGW to get SSH functionality. Alternatively you can just enable Telnet which is native to Windows, but much less secure than SSH.

ubiquibacon

Posted 2012-01-06T01:10:19.730

Reputation: 7 287