参考原文链接:
- https://blog.youkuaiyun.com/u013894429/article/details/78811823
- https://blog.youkuaiyun.com/wugenqiang/article/details/86554753
参考资料
- 《阿里云服务器怎么用?阿里云服务器使用教程》
http://www.cr173.com/html/50758_1.html
- eagle-zhang的优快云博客《Xshell连接不上阿里云服务器》
http://blog.youkuaiyun.com/zhangxing52077/article/details/78048254
步骤
阿里云控制台相关配置
- 通过阿里云控制台的云服务器ECS进入到云服务器管理控制台。点击左侧
实例
选项显示实例列表。
- 在实例列表里,点击对应实例左侧蓝色字符进入到实例信息界面。点击右面窗口的基本信息旁的
远程连接
,远程管理云服务器从而激活服务器。
- 配置端口。点击左侧界面中的
本实例安全组
,进入到安全列表组界面。点击对应安全组ID/名称
行右侧的配置规则
,进入到安全组规则设置界面。
- 点击界面右上方的
添加安全组规则
的按钮,弹出“编辑安全组规则”窗口。设置如下:
其中:- 协议类型:
SSH(22)
- 授权对象:
0.0.0.0/0
(表示任何IP地址均可进行访问)
- 协议类型:
Xshell连接
在Shell进行新建连接,其中主机
一栏填入对应的云服务器的公网IP地址。点击确定后输入账号密码连接到对应云服务器。
可能存在问题
- xshell出现WARNING!The remote SSH server rejected X11 forwarding request.
解决方法:
- 设置sshd_config
打开sshd_config
nano /etc/ssh/sshd_config
在X11这行改为X11Forwarding yes,
然后再将UseLogin参数为no,可能这一行最开始是被注释,去掉注释
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
UseLogin no
UsePrivilegeSeparation sandbox # Default for new installations.
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none
保存之后重启sshd服务,重新连接即可
systemctl restart sshd
如果还不行检查 xorg-x11-xauth 的rpm包是否安装,未安装则进行下面操作
yum install xorg-x11-xauth