runpod team 怎么设置自己的ssh key呢?
生成 ed25519 公钥密钥
ssh-keygen -t ed25519 -C "your@qq.com"
然后在pod容器配置key以及启动方式
选择edit pod
添加启动代码
启动代码可以参考官方给的内容:
- https://docs.runpod.io/pods/configuration/use-ssh
bash -c 'apt update;DEBIAN_FRONTEND=noninteractive apt-get install openssh-server -y;mkdir -p ~/.ssh;cd $_;chmod 700 ~/.ssh;echo "$PUBLIC_KEY" >> authorized_keys;chmod 700 authorized_keys;service ssh start;sleep infinity'
我建议是在公有环境配置自己的key的,这样可以随时删除
怎么vscode连接呢?
默认是root账号,但是不建议root账号,应该开设自己的账号
#!/usr/bin/env bash
set -euo pipefail# 1. 定义新用户名和密码
USERNAME="Guanjq"
PASSWORD="YourSecurePasswordHere" # 建议使用交互式或密钥方式,不在脚本中明文存放# 2. 创建用户并设置密码
if id "$USERNAME" &>/dev/null; thenecho "用户 $USERNAME 已存在,跳过创建。"
elseecho "创建用户 $USERNAME ..."useradd -m -s /bin/bash "$USERNAME" # 创建用户并生成 home 目录 :contentReference[oaicite:0]{index=0}echo "$USERNAME:$PASSWORD" | chpasswd # 设置用户密码 :contentReference[oaicite:1]{index=1}echo "用户 $USERNAME 创建完成。"
fi# 3. 将用户加入 sudo(在 Debian/Ubuntu 为 sudo 组,CentOS/RHEL 为 wheel 组)
if grep -Eiq "ubuntu|debian" /etc/os-release; thenSUDOGROUP="sudo"
elseSUDOGROUP="wheel"
fiecho "将 $USERNAME 添加到 $SUDOGROUP 组 ..."
usermod -aG "$SUDOGROUP" "$USERNAME" # 授予 sudo 权限 :contentReference[oaicite:2]{index=2}# 5. 重启 SSH 服务
echo "重启 SSH 服务..."
if systemctl is-active --quiet sshd; thensystemctl reload sshd # 推荐 reload 而非 restart :contentReference[oaicite:3]{index=3}
elsesystemctl start sshd
fiecho "完成!现在请以新用户 $USERNAME 登录,并使用 sudo 进行管理。"