方法一
一,设置 root 密码
- 先选择从浏览器打开 ssh 连接服务器
- 切换到 root 账号,输入代码:
sudo -i
- 设置 root 密码,输入代码:
passwd
二,开启 SSH 权限
- CentOS 和 Debian 通用,输入以下命令
sed -i 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config && sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
- Ubuntu 系统,输入以下命令
sed -i 's/ #PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config && sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config
- 重启服务器 :
reboot
方法二
切换到root角色 (和前面步骤一样)
sudo -i
修改SSH配置文件/etc/ssh/sshd_config
vi /etc/ssh/sshd_config
修改PermitRootLogin
和PasswordAuthentication
为yes
# Authentication:
PermitRootLogin yes //默认为no,需要开启root用户访问改为yes
# Change to no to disable tunnelled clear text passwords
PasswordAuthentication yes //默认为no,改为yes开启密码登陆
给root用户设置密码
passwd root
重启SSH服务使修改生效
/etc/init.d/ssh restart
以上就是谷歌云设置 ROOT 用户以及允许第三方 SSH 登录教程。
方法三
本地用xshell生成密秘钥
这里有个坑: 第6步的时候要点击下一步
图片点击放大
将秘钥配置到谷歌云上
菜单 — 计算引擎 — 元数据 — SSH秘钥 — 修改 — 添加一项
粘贴刚才从xshell复制的秘钥。在末尾添加 [空格][用户名] 这里就是“ google”,保存即可。
用xshell连接
连上之后,输入命令 sudo -i
切换到root用户.
三,一键重装脚本
系统更新
apt update -y && apt install -y wget sudo
防止报错: Error! grub.cfg
mkdir /boot/grub2 && grub-mkconfig -o /boot/grub2/grub.cfg
一键脚本 (ubuntu 20.04)时间半个小时吧,耐心等待就行
bash <(wget --no-check-certificate -qO- 'https://raw.githubusercontent.com/MoeClub/Note/master/InstallNET.sh') --ip-addr 10.146.0.3 --ip-gate 10.146.0.1 --ip-mask 255.255.255.0 -u 20.04 -v 64 -p 123456 -port 22
debian10
bash <(wget --no-check-certificate -qO- 'https://raw.githubusercontent.com/MoeClub/Note/master/InstallNET.sh') --ip-addr 10.148.0.5 --ip-gate 10.148.0.1--ip-mask 255.255.255.0 -d 10 -v 64 -p 123456 -port 22
仅适用于谷歌云 (密码:123456 ) SSH 端口: 22
参数修改
- 10.146.0.3 谷歌云 VPS 内网 IP 谷歌云后台去找
- 10.146.0.1 谷歌云 VPS 内网 IP 的网关前三位数和 IP 相同第四位数为 1
系统参数
-d 10 【7、8、9、10,11】Debian
-u 20.04 【14.04、16.04、18.04、20.04】Ubuntu
四,系统更新
apt update -y && apt full-upgrade -y && apt install -y curl wget sudo socat