VS Code Remote SSH with Jailkit shell user

Discussion in 'Installation/Configuration' started by Evan Connolly, Jan 11, 2023.

  1. Evan Connolly

    Evan Connolly New Member

    Hi all,

    I'm trying to get VS Code with the Remote SSH extension working with a shell user and jailkit enabled for that user. Everything works without jailkit, so ssh is configured correctly.

    At first it complained about some missing commands, so I added the following with "jk_cp -k -j ... " to the jail

    /usr/bin/flock
    /usr/bin/ps
    /usr/bin/printenv
    /bin/env
    /usr/bin/readlink
    /etc/shells

    Then it complained about the missing /proc, so I mounted it inside the shell too.

    Now the editor part of VS Code works, but not the buit-in terminal. I get a notification with the message

    "The terminal process failed to launch: A native exception occurred during launch (forkpty(3) failed.)."

    Did anyone else get this working? And does anything regarding security speaks against the steps above?
     
  2. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    What is your OS? Which version of Jailkit? Which version of ISPConfig? Did you create the user with Jailkit in the beginning or switched it later? Have you tried creating a new user with Jailkit enabled immediately?

    If the Jail is not OK, it is better to fix the jailkit configuration instead of manually trying to fix it.
     
  3. Evan Connolly

    Evan Connolly New Member

    Ubuntu Server 20.04 LTS

    It looks like 2.21-2. I thought it came as a dependency of ISPConfig. I didn't install it.

    3.2.8p2

    I created the shell user without jailkit enabled originally. I tried again with a new shell user and the same happens.

    I wasn't aware of that I needed to configure anything. I left everything in the default configuration. Ok, I could create a [vscode] section in /etc/jailkit/jk_init.ini and put all the commands I added manually in there. But what would that change? The result will be the same as I don't know what I'm missing to get the terminal inside vscode working.

    Hence my question if somebody got vscode working. Some Google hits suggest it could be the missing /dev/pts. I will look into it further tomorrow.
     
  4. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

  5. Evan Connolly

    Evan Connolly New Member

    Yeah, that's what I found yesterday and where I got the idea about /dev/pts from.
    Deleting .vscode-server on the remote host didn't work. Also changing the permissions of .../dev/pts/ptmx and creating a symlink .../dev/pts/ptmx -> .../dev/ptmx didn't work.

    When I remove jailkit from the schell user, the following happens. Before starting vscode /dev/pts looks like this
    drwxr-xr-x 2 root root 0 Jan 12 12:29 ./
    drwxr-xr-x 17 root root 4000 Jan 12 12:29 ../
    crw------- 1 root tty 136, 0 Jan 12 12:41 0
    crw--w---- 1 root tty 136, 1 Jan 12 12:41 1
    c--------- 1 root root 5, 2 Jan 12 12:29 ptmx

    After vscode connecting and opening the terminal it looks like this
    drwxr-xr-x 2 root root 0 Jan 12 12:29 ./
    drwxr-xr-x 17 root root 4000 Jan 12 12:29 ../
    crw------- 1 root tty 136, 0 Jan 12 12:44 0
    crw--w---- 1 root tty 136, 1 Jan 12 12:44 1
    crw--w---- 1 web12 tty 136, 2 Jan 12 12:44 2
    crw--w---- 1 web12 tty 136, 3 Jan 12 12:44 3
    crw--w---- 1 web12 tty 136, 4 Jan 12 12:44 4
    crw--w---- 1 web12 tty 136, 5 Jan 12 12:44 5
    crw--w---- 1 web12 tty 136, 6 Jan 12 12:44 6
    c--------- 1 root root 5, 2 Jan 12 12:29 ptmx

    So it looks like with jailkit enabled the files inside .../dev/pts are or cannot be created.
     
  6. Fire Fox

    Fire Fox Member

    this may help,
    go to user settings (UI) and tick 'Always reveal the SSH login terminal'
    upload_2023-7-21_20-25-16.png

    vscode will give you the Terminal and stop complaining about "The terminal process failed to launch: A native exception occurred during launch (forkpty(3) failed.).
     

    Attached Files:

Share This Page