如何在 GCP 中获得对 AI Platform 笔记本的 root 访问权限?

sri*_*rao 7 google-cloud-platform gcp-ai-platform-notebook

jupyter在 GCP AI Platform 笔记本实例的终端中以用户身份登录。

\n

我只想安装一些东西(无法通过 pip 安装),但无法使用 gcloud 命令以 root 用户身份进行 ssh。

\n

如果有人可以分享获得执行这些操作的权限的正确方法的指针,那就太好了。

\n

以下是导致问题的示例包安装的片段 -

\n
(base)~/datascience$ sudo cp ./pip-bash-completion/pip /etc/bash_completion.d/\n\nWe trust you have received the usual lecture from the local System\nAdministrator. It usually boils down to these three things:\n\n    #1) Respect the privacy of others.\n    #2) Think before you type.\n    #3) With great power comes great responsibility.\n\n[sudo] password for jupyter: \n
Run Code Online (Sandbox Code Playgroud)\n

sudo根据我看到的信息,我应该有权访问 -

\n
(base)~/datascience$ sudo cp ./pip-bash-completion/pip /etc/bash_completion.d/\n\nWe trust you have received the usual lecture from the local System\nAdministrator. It usually boils down to these three things:\n\n    #1) Respect the privacy of others.\n    #2) Think before you type.\n    #3) With great power comes great responsibility.\n\n[sudo] password for jupyter: \n
Run Code Online (Sandbox Code Playgroud)\n

gog*_*sca 1

如果您在 Jupyter 终端中,则应该使用sudo. 一些 IT 管理员通过使用notebook-disable-root=true元数据来限制 root 访问。您可以通过访问 Cloud Console 中的笔记本页面来验证这一点。

创建禁用 root 的新实例的示例:

gcloud notebooks instances create $INSTANCE_NAME \
  --vm-image-project=deeplearning-platform-release \
  --vm-image-family=tf-latest-gpu \
  --metadata="notebook-disable-root=true,proxy-mode=mail,proxy-user-mail=user@company.com" \
  --location=us-west1-a
Run Code Online (Sandbox Code Playgroud)

Google Cloud AI Platform 笔记本通过 OSLogin 支持 SSH。https://cloud.google.com/compute/docs/oslogin/manage-oslogin-in-an-org 您需要使用 IAM 帐户进行 SSH,然后执行 sudo。