且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用SSH使用密码连接到GCP VM实例?

更新时间:2022-06-22 09:42:04

默认情况下,在新创建的Linux Compute Engine上,使用密码(而不是密钥)的SSH登录被禁用.幸运的是,可以很快启用它.

By default, SSH login using a password (as opposed to keys) is disabled on newly created Linux Compute Engines. Fortunately, it can be enabled pretty quickly.

登录到Linux环境,然后编辑位于以下位置的文本文件:

Login to the Linux environment and then edit the text file found at:

/etc/ssh/sshd_config

查找以下内容:

PasswordAuthentication no

并将其更改为

PasswordAuthentication yes

保存文件.

最后,使用以下命令重新启动SSH:

Finally, restart SSH using:

sudo service ssh restart

这时,您现在将能够使用SSH使用用户ID/密码对进行登录.
要设置 $ USER 的密码,请执行以下操作:

At this point, you will now be able to login using SSH using a userid/password pair.
To set the password for $USER, do:

sudo passwd $USER

参考文献: