17

On my work Mac, which stays physically in my work office, I want to keep my work stuff separate from my personal stuff by using two different user accounts. I normally stay logged in as the 'work' user. But I want to have them visible at the same time, since I have a large screen. I think I could get a nice setup if I could use the built in remote desktop client or a 3rd party VNC client to connect to the login screen of the existing machine, so that I can select a different user. Or if I could connect as a specific user, even though the physical machine is already logged in as someone else.

I normally use my system with "remote management" mode enabled (not just remote desktop), and I often use a VNC client at home to access my Mac desktop at work. Although this is not my daily routine. In this mode the VNC client immediately connects to the existing desktop. Is there a way I can force this connection to go to the login screen instead? When I use a VNC client to connect to the existing screen, I can see it trying (you get the kind of infinite regress that you might expect), so the basic connection works. I just want it to let me select another user.

Edit: I think part of the problem is that the system might be running a VNC server session in the background waiting for me to connect. It connects to the active session. It seems to happen either when I have "remote management" turned on or just "screen sharing". Using an alternate user in an "open" command results in an error about not being able to control your own screen.

To be clear, both accounts are on my work computer. From home I want to connect to my "work user" on my work computer. From my desk at work, logged in as my "work user" I want to be able to connect to the "personal user" on my work computer.

I think my real problem is related to what happens on the server side of the connection. I want the OS to fire up the login window even through there is a user logged in on the main screen/keyboard. I know that is some circumstances a remote-login user can receive the login screen. It might be necessary for me to give up the idea of sometimes connecting to the logged-in user and sometimes connecting with a fresh login. If I can switch completely to the fresh-login mode that would be a start.

How does Mac OS decide whether to show the login-screen for a remote connection versus just connecting you to the running desktop? I thought it was related to having "remote management" turned on vs "screen sharing". But with just "screen sharing" turned on, I still get the connect-to-existing behavior.

1
  • I would like to ask is there any defaults write hack that relax the restriction of Screen Sharing.app, or is there a recommendation for free VNC viewer?
    – amdyes
    Nov 15, 2019 at 3:18

5 Answers 5

19

ARD into your "work account" and then do the following on the remote computer to open a Screen Sharing window to your "personal account" on the same remote computer.

Create an SSH tunnel. It works for me using 10.9.

Enable Remote Login (SSH) in System Preferences > Sharing, and in Terminal run:

ssh -NL 5901:localhost:5900 localhost

Finally, use Screen Sharing to connect to localhost:5901 (instead of the default port 5900). Instead of port 5901 you can use a much higher port that isn't in use by anything else.

The Screen Sharing application is located here: /System/Library/CoreServices/Screen Sharing.app

6
  • This just redirects 5901 to 5900 right? It doesn't actually run a new remote login process on the server side. Nov 4, 2014 at 1:40
  • SSH manpage:: -L Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side. :: -N Do not execute a remote command. This is useful for just forwarding ports (protocol version 2 only). Nov 7, 2014 at 23:47
  • Oh my god, that's great! Finally I can quickly check things like localized strings in menus without resorting to virtual machines or logging out and back in!
    – Asmus
    Dec 12, 2014 at 13:14
  • This indeed is great, finally something like nested X on Linux. It's working on Sierra. Having another user's account opened on second virtual desktop is much better than constantly switching accounts.
    – Mr. Tao
    Oct 23, 2016 at 20:24
  • 1
    This is still working under 10.14 Mojave. For novices like me, I'd add a couple things that gave me momentary confusion: 1. you type the ssh command in Terminal on the account you want to remote INTO (let's call it account 1) and leave that process running in the Terminal. Terminal will wan you about the "authenticity of host 'localhost' but that seems to be normal. The only feedback you'll see that the SSH process is working is in the title bar of the Terminal window. 2. When you launch Screen Sharing, you do that in the account you want to remote FROM (calling this account 2).
    – Gorb
    Dec 23, 2018 at 18:25
4

You can specify a specific user using the open command in terminal.

open vnc://user:password@hostname(or IP)

This is also achievable through Go Connect to Server ( cmd + k) from the finder and entering vnc://hostname(or IP)

You can only have two users running on one machine remotely.

5
  • 2
    With 10.9 both of these say, "You can't control your own computer." They both effectively open up Screen Sharing which won't allow it. Oct 18, 2014 at 2:05
  • I get the message about "You cannot control your own screen". Oct 18, 2014 at 2:10
  • I see from your edit above that that isn't possibly. Have you tried connecting to each user from your home computer separately.
    – tron_jones
    Oct 18, 2014 at 2:23
  • I was able to get it to work via my explanation Oct 22, 2014 at 22:49
  • If you got a fresh-login screen on the same machine, which a user already logged in, please tell me what items you have turned on it the 'Sharing' settings. Nov 4, 2014 at 1:43
3

To clarify @mindmischief answer, here are the steps to set it up:

  1. (optional) Create a new user (e.g. vnc) in Preferences/Users with the password.
  2. In Preferences/Sharing, enabled Screen Sharing and Remote Login (also Allow access for it).
  3. Verify that ssh vnc@localhost works.
  4. Run: ssh -NL 5901:localhost:5900 vnc@localhost (as per this post).

Note: You can use different user than vnc. For debug, add -vvv to your ssh command.

Now open the VNC connection by the following command:

open vnc://localhost:5901/
2
  • how is creating a new user optional? How can i connect without having a user? It seems you have to specify one under "Allow access for:"
    – trainoasis
    Jun 19, 2018 at 6:50
  • @trainoasis You could always ssh to another existing user.
    – kenorb
    Jun 19, 2018 at 9:03
0

Nowadays this works out of the box with the built-in “Screen Sharing” feature (which is just a built-in VNC server).

Go to “System Preferences → Sharing” and enable “Screen Sharing” for all users. Now each user account will be able to connect using any VNC client and log into their own session.

0

I can confirm that this is still working on Big Sur, no issues, but you must set up the SSH tunnel per the top answer above and then use screen sharing for VNC (Apple's built-in screen share app works better than VNC, IMHO).

Failure to set up SSH tunnel throws an error "You Cannot Control Your Own Screen".

1
  • 1
    We are looking for answers which stand on their own and don't rely on other answers to be meaningful. Also, users can have different sort orders, so their "top answer" may be different from yours. Please edit your question to include all relevant details.
    – nohillside
    Sep 28, 2021 at 18:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .