在第三方 SSH 上连接 Google Cloud Platform 虚拟机
题图:Made By Bannersnack
具体方法
进入自己的GCP账号
进入VM 实例
选择需要用SSH登陆的VM, 点击SSH
切换到 root 账号:
1
sudo -i
设置 root 密码:
1
passwd
然后会要求输入新密码,然后再重复一次密码。
1
2
3Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully修改 SSH 配置文件:
1
vi /etc/ssh/sshd_config
再输入
i
进入编辑
修改以下内容(从上到下):
修改 22 端口状态,并设置为打开:
1
2
3
4Port 22
AddressFamily any
ListenAddress 0.0.0.0
ListenAddress ::将Port 22前面的#去除,修改为
1
2
3
4Port 22
AddressFamily any
ListenAddress 0.0.0.0
ListenAddress ::允许 root 用户访问:
1
2
3
4
5
6
7Authentication:
LoginGraceTime 2m
PermitRootLogin prohibit-password
StrictModes yes
MaxAuthTries 6
MaxSessions 10将PermitRootLogin前面的#去除,并修改为
1
2
3
4
5
6
7Authentication:
LoginGraceTime 2m
PermitRootLogin yes
StrictModes yes
MaxAuthTries 6
MaxSessions 10开启密码登陆:
1
2
3To disable tunneled clear text passwords, change to no here!
PasswordAuthentication no
PermitEmptyPasswords no将PasswordAuthentication修改为
1
2
3To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes
PermitEmptyPasswords no按下
esc
键盘,再输入:wq
保存退出重启
1
sudo reboot
完成
可以用第三方SSH客户端连接,或者使用
1
ssh -p portID [email protected]
连接SSH即可
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.