谷歌云默认是使用浏览器的SSH客户端进行连接
安全性来说这样是最高等级的,但是有时候我们为了方便也需要外部SSH客户端进行管理
具体步骤如下:
1、先使用谷歌云VM实例控制台的浏览器方式登陆进去SSH
2、切换到root角色
sudo -i
3、修改SSH配置文件
vi /etc/ssh/sshd_config
4、找到需要修改的两个条目
在这附近:
# Authentication:
#LoginGraceTime 2m
PermitRootLogin no
# Authentication:
#LoginGraceTime 2m
PermitRootLogin no
修改PermitRootLogin为yes
以及:
在这附近:
# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication no
# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication no
修改PasswordAuthentication为yes
5、给root用户设置密码
passwd root
6、重启SSH服务使修改生效
service sshd restart
注:默认端口为22,重启SSH服务之后即可使用Xshell或者FinalShell等软件登陆
7、更改SSH默认连接端口
执行:
vi /etc/ssh/sshd_config
找到#Port 22
修改为Port 20000
或自己想要的端口
然后:wq保存vi编辑器
8、修改firewall配置
执行:
firewall-cmd --zone=public --add-port=20000/tcp --permanent
其中20000改为和上面一样的新SSH端口
重新加载防火墙规则:
firewall-cmd --reload
验证规则添加成功:
firewall-cmd --zone=public --query-port=20000/tcp
最后重启SSH服务即可:
service sshd restart