Ubuntu
Chroot 在 Ubuntu 14.04.2 上使用 Jailkit - /dev/pts 沒有這樣的文件或目錄
在過去的幾天裡,我一直試圖在我的 Ubuntu 伺服器上設置一個 chroot,但我遇到了一個問題。我嘗試了幾種在 Ubuntu 上設置 chroot 的不同方法,包括自己手動設置文件夾權限,然後為我想要允許的二進製文件靜態連結庫,但目前我正在使用 Jailkit 設置 chroot 環境但是使用這兩種設置我都遇到了同樣的問題,在設置 chroot 並嘗試登錄 ssh 後,我立即受到強制關閉終端的歡迎。當我執行調試 sshd 時,我發現這是因為 sshd 由於某種原因無法找到 /dev/pts,即使它位於 chroot 環境中。
這是我的設置,它全部由 Jailkit 填充,除了 /dev/pts 使用
sudo mount -o bind /dev/pts /data/jail/dev/pts /data/jail/home/user /data/jail/dev /data/jail/dev/pts /data/jail/dev/tty
這是調試 sshd 顯示的內容:
debug3: safely_chroot: checking '/' debug3: safely_chroot: checking '/data/' debug3: safely_chroot: checking '/data/jail/' debug3: safely_chroot: checking '/data/jail/home/' debug3: safely_chroot: checking '/data/jail/home/user' Changed root directory to "/data/jail/home/user" debug1: permanently_set_uid: 1002/1003 debug2: set_newkeys: mode 0 debug2: set_newkeys: mode 1 debug1: Entering interactive session for SSH2. debug2: fd 6 setting O_NONBLOCK debug2: fd 8 setting O_NONBLOCK debug1: server_init_dispatch_20 debug3: Received SSH2_MSG_IGNORE debug1: server_input_channel_open: ctype session rchan 256 win 16384 max 16384 debug1: input_session_request debug1: channel 0: new [server-session] debug2: session_new: allocate (allocated 0 max 10) debug3: session_unused: session id 0 unused debug1: session_new: session 0 debug1: session_open: channel 0 debug1: session_open: session 0: link with channel 0 debug1: server_input_channel_open: confirm session debug1: server_input_channel_req: channel 0 request pty-req reply 1 debug1: session_by_channel: session 0 channel 0 debug1: session_input_channel_req: session 0 req pty-req debug1: Allocating pty. debug3: mm_request_send entering: type 28 debug3: mm_pty_allocate: waiting for MONITOR_ANS_PTY debug3: mm_request_receive_expect entering: type 29 debug3: mm_request_receive entering debug3: mm_request_receive entering debug3: monitor_read: checking request 28 debug3: mm_answer_pty entering debug2: session_new: allocate (allocated 0 max 10) debug3: session_unused: session id 0 unused debug1: session_new: session 0 debug1: SELinux support disabled debug3: mm_request_send entering: type 29 debug3: mm_answer_pty: tty /dev/pts/8 ptyfd 5 debug1: session_pty_req: session 0 alloc /dev/pts/8 debug1: server_input_channel_req: channel 0 request shell reply 1 debug1: session_by_channel: session 0 channel 0 debug1: session_input_channel_req: session 0 req shell Starting session: shell on pts/8 for user from *.*.*.* port 54006 debug2: fd 3 setting TCP_NODELAY debug3: packet_set_tos: set IP_TOS 0x10 debug2: channel 0: rfd 11 isatty debug2: fd 11 setting O_NONBLOCK debug3: fd 9 is O_NONBLOCK debug1: Setting controlling tty using TIOCSCTTY. /dev/pts/8: No such file or directory open /dev/tty failed - could not set controlling tty: No such file or directory debug3: mm_request_receive entering debug3: monitor_read: checking request 156 debug3: mm_answer_consolekit_register entering debug1: session_by_tty: session 0 tty /dev/pts/8 debug1: Unable to open session: The name org.freedesktop.ConsoleKit was not provided by any .service files
據我所知,
ChrootDirectory
沒有正確設置。它應該設置為:
ChrootDirectory /data/jail