获取root权限,编辑配置文件:

sudo su
vi /etc/ssh/sshd_config

将PermitRootLogin值改为yes:

PermitRootLogin yes

重启ssh

/etc/init.d/ssh restart

在gcp控制面板->vm实例->ssh密钥处添加公钥登陆提示:

Please login as the user "ubuntu" rather than the user "root"Please login as the user "ubuntu" rather than the user "root"

后来才发现配置的公钥在默认放在了/home/ubuntu/下,复制到/root/.ssh/下解决问题🤣

sudo cp /home/ubuntu/.ssh/authorized_keys /root/.ssh/