如何使用 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} {new user name}
命令添加了用户,并使用 passwd {new user name}<更改了密码/code> 命令.
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 实例,但收到此错误:Permission denied (publickey).
I tried to connect to the VM instance with SSH but i received this error: Permission denied (publickey).
请帮帮我.
推荐答案
默认情况下,在新创建的 Linux 计算引擎上禁用使用密码(而不是密钥)的 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
此时,您现在可以使用用户 ID/密码对使用 SSH 登录.
要为 $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屋!