Google Cloud Platform(GCP)实例开启密码与root用户登陆

/ 0评 / 0

Google Cloud Platform创建的VM实例(以下简称GCP)上出于安全性考虑,只允许通过ssh key登陆并禁用了root登陆。由于Google赠送300美元一年期代金券,很多用户只是为了搭个梯子或者随便玩玩,对安全性要求不高,自然没必要通过ssh key那么麻烦,以下介绍以下开启密码登陆与root登陆流程。

注意!以下操作会降低登陆安全性,请自行斟酌是否开启

系统为默认的Ubuntu 16.x,其他发行版可参考以下步骤进行。

1、在GCP VM实例列表中,选择“在浏览器窗口中打开”访问实例

2、通过sudo su命令切换到root用户

sudo su //切换到root用户

3、修改SSH配置文件/etc/ssh/sshd_config

vi /etc/ssh/sshd_config //编辑文件

找到PermitRootLogin和PasswordAuthentication

# Authentication:
LoginGraceTime 120
PermitRootLogin yes //默认为no,需要开启root用户访问改为yes
StrictModes yes
 
# Change to no to disable tunnelled clear text passwords
PasswordAuthentication yes //默认为no,改为yes开启密码登陆

4、重启SSH服务使修改生效

/etc/init.d/ssh restart

5、进行以下操作,可使用putty等客户端通过用户名和密码访问实例

 

发表评论

邮箱地址不会被公开。 必填项已用*标注