Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tailscale ssh doesn't work with the macOS sandbox app #4518

Open
maisem opened this issue Apr 25, 2022 · 6 comments
Open

tailscale ssh doesn't work with the macOS sandbox app #4518

maisem opened this issue Apr 25, 2022 · 6 comments

Comments

@maisem
Copy link
Contributor

@maisem maisem commented Apr 25, 2022

What is the issue?

$ /Applications/Tailscale.app/Contents/MacOS/Tailscale ssh ws-1
Pseudo-terminal will not be allocated because stdin is not a terminal.
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535

Steps to reproduce

Run /Applications/Tailscale.app/Contents/MacOS/Tailscale ssh <host> on any macOS machine, where <host> is any Tailscale node.

Are there any recent changes that introduced the issue?

No response

OS

macOS

OS version

12.2.1

Tailscale version

1.24

Bug report

No response

@bradfitz
Copy link
Member

@bradfitz bradfitz commented Apr 25, 2022

It's likely this just won't work in the App Store version.

We might have to detect that version and said, "Sorry, use a different macOS version."

/cc @nickoneill @crawshaw

bradfitz added a commit that referenced this issue Apr 26, 2022
Still a little wonky, though. See the tcsetattr error and inability to
hit Ctrl-D, for instance:

    bradfitz@laptop ~ % tailscale.app ssh foo@bar
    tcsetattr: Operation not permitted
    # Authentication checked with Tailscale SSH.
    # Time since last authentication: 1h13m22s
    foo@bar:~$ ^D
    ^D
    ^D

Updates #4518
Updates #4529

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
@bradfitz
Copy link
Member

@bradfitz bradfitz commented Apr 26, 2022

As of #4531 it's better, but still not great. See the tcsetattr error and inability to
hit Ctrl-D, for instance:

    bradfitz@laptop ~ % tailscale.app ssh foo@bar
    tcsetattr: Operation not permitted
    # Authentication checked with Tailscale SSH.
    # Time since last authentication: 1h13m22s
    foo@bar:~$ ^D
    ^D
    ^D

bradfitz added a commit that referenced this issue Apr 26, 2022
Still a little wonky, though. See the tcsetattr error and inability to
hit Ctrl-D, for instance:

    bradfitz@laptop ~ % tailscale.app ssh foo@bar
    tcsetattr: Operation not permitted
    # Authentication checked with Tailscale SSH.
    # Time since last authentication: 1h13m22s
    foo@bar:~$ ^D
    ^D
    ^D

Updates #4518
Updates #4529

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
bradfitz added a commit that referenced this issue Apr 26, 2022
Still a little wonky, though. See the tcsetattr error and inability to
hit Ctrl-D, for instance:

    bradfitz@laptop ~ % tailscale.app ssh foo@bar
    tcsetattr: Operation not permitted
    # Authentication checked with Tailscale SSH.
    # Time since last authentication: 1h13m22s
    foo@bar:~$ ^D
    ^D
    ^D

Updates #4518
Updates #4529

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
maisem pushed a commit that referenced this issue Apr 27, 2022
Still a little wonky, though. See the tcsetattr error and inability to
hit Ctrl-D, for instance:

    bradfitz@laptop ~ % tailscale.app ssh foo@bar
    tcsetattr: Operation not permitted
    # Authentication checked with Tailscale SSH.
    # Time since last authentication: 1h13m22s
    foo@bar:~$ ^D
    ^D
    ^D

Updates #4518
Updates #4529

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
(cherry picked from commit 50eb8c5)
maisem pushed a commit that referenced this issue Apr 27, 2022
Still a little wonky, though. See the tcsetattr error and inability to
hit Ctrl-D, for instance:

    bradfitz@laptop ~ % tailscale.app ssh foo@bar
    tcsetattr: Operation not permitted
    # Authentication checked with Tailscale SSH.
    # Time since last authentication: 1h13m22s
    foo@bar:~$ ^D
    ^D
    ^D

Updates #4518
Updates #4529

Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
(cherry picked from commit 50eb8c5)
@mayakacz
Copy link
Contributor

@mayakacz mayakacz commented May 6, 2022

I think you are saying that macOS won't work as the server you SSH to, but it should still work fine as the client you SSH from. (Or are you saying the client will not work?)

@bradfitz
Copy link
Member

@bradfitz bradfitz commented May 6, 2022

MacOS with Tailscale wrapper client won't work well. Bad enough to be embarrassing and will invite tons of dup bugs we'll be unable to do anything about.

MacOS with system ssh client is fine. We just don't get the magic host key checking bit yet.

bradfitz added a commit that referenced this issue Jun 6, 2022
Updates #3802
Updates #4518
Fixes #4628

Change-Id: I194d2cc30fc8e38b66d4910787efbce14317b0ff
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
bradfitz added a commit that referenced this issue Jun 6, 2022
Updates #3802
Updates #4518
Fixes #4628

Change-Id: I194d2cc30fc8e38b66d4910787efbce14317b0ff
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Soypete pushed a commit that referenced this issue Jun 14, 2022
Updates #3802
Updates #4518
Fixes #4628

Change-Id: I194d2cc30fc8e38b66d4910787efbce14317b0ff
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
@mihaip
Copy link
Contributor

@mihaip mihaip commented Jun 30, 2022

I looked into this a bit. The tcsetattr: Operation not permitted is due to not being able to set the tty in raw mode at https://github.com/openssh/openssh-portable/blob/2dc328023f60212cd29504fc05d849133ae47355/sshtty.c#L93.

I thought that this was maybe due to the ssh process not inheriting some permissions, so I tried doing this directly in the ssh.go CLI command (via termios.Raw), but that got the same permission error.

Looking at the console, there is a Sandbox: ssh(10318) deny(1) file-ioctl /dev/ttys001 line (tcsetattr is implemented in terms of ioctl), which suggests that this is indeed a sandbox limitation.

Looking at the default sandbox profile for apps (/System/Library/Sandbox/Profiles/application.sb), there are a few places where file-ioctl is allowed: (allow file-read* file-write* file-ioctl (literal "/dev/ptmx")) and something relating to application groups that I don't think is relevant.

Can we perhaps use /dev/ptmx (which can be put into raw mode) and connect it to stdin?

This may also be something for @nickoneill to bring up at the next WWDC. I can also try to make a self-contained sample and see if Quinn or someone else from Apple in their forums has ideas.

@mihaip
Copy link
Contributor

@mihaip mihaip commented Jun 30, 2022

Posted https://developer.apple.com/forums/thread/709444 on Apple's forums.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants