如何使用SSH使用密码连接到GCP VM实例? [英] How to connect to GCP VM instance with password using SSH?
问题描述
我能够使用SSH密钥连接到GCP中的VM实例.我使用 sudo useradd -m -s/bin/bash -G {groups} {新用户名}
命令添加了用户,并使用 passwd {新用户名}
命令.
I able to connect to my VM instance in GCP with a SSH key.
I added user with the sudo useradd -m -s /bin/bash -G {groups} {new user name}
command, and changed the password with th passwd {new user name}
command.
我尝试使用SSH连接到VM实例,但收到以下错误:权限被拒绝(公钥).
I tried to connect to the VM instance with SSH but i received this error: Permission denied (publickey).
请帮助我.
推荐答案
默认情况下,在新创建的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
参考文献:
这篇关于如何使用SSH使用密码连接到GCP VM实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!