REDHAT 7(Gnome 3)上的 telnet x11

REDHAT 7(Gnome 3)上的 telnet x11

过去两周,我一直在尝试让 X11 应用程序通过 telnet 连接到服务器。我并不担心安全性,因为我也在服务器位置运行 VPN。我只需要 X11 一直工作,因为我打开了很多应用程序。我在远程机器上做了以下事情:

export DISPLAY=host-ip-address:0.0

在我的本地机器上:

xhost +remote-server-address

然后我还将以下内容添加到我的/etc/gdm/custom.conf

[security]
DisallowTCP=false

我重启了电脑。但这还不够。我还检查了 6000 是否在监听:

$ netstat -a --numeric-ports | grep 6000
tcp        0      0 0.0.0.0:6000            0.0.0.0:*               LISTEN     
tcp6       0      0 [::]:6000               [::]:*                  LISTEN     

这是我别无选择的地方,需要一些帮助。有人知道为什么 X11 不起作用吗?我试过了,ssh -Xf但它不适合我。因为我总是打开和关闭 X11 应用程序。当我关闭用 ssh 打开的原始应用程序时,我无法再打开任何应用程序。我有一个不同的问题我已经打开它了,但我还没有收到回复。

编辑:我收到了回复,并尝试了,但没有帮助。我必须安装yum install iptables-services才能在我的系统上安装 iptables。

/etc/sysconfig/iptables然后我在我的文件中添加了以下内容:

-A INPUT -p tcp -m tcp --dport 6000 -m state --state NEW -j ACCEPT

我甚至使用 重启了 iptables 服务service iptables restart。但仍然无法正常工作。还有其他想法吗?

编辑2:我的输出iptables -L

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
ACCEPT     icmp --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:ssh
REJECT     all  --  anywhere             anywhere             reject-with icmp-host-prohibited
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:x11 state NEW

我是否应该删除 REJECT 行?

答案1

不建议打开 X 服务器的端口,SSH 确实是更好的选择。任何闯入远程服务器的人都可以打开 X 服务器上的程序、捕获按键、查看屏幕等。因此,您必须能够信任远程服务器。

无论如何,下面的代码应该适用于 CentOS 6,也可能适用于 Redhat 7。您需要编辑的文件是/etc/sysconfig/iptables(以 root 身份!)。它应该以类似以下内容开始:

# Generated by iptables-save v1.3.5 on Sun May 11 18:20:27 2014
*filter
:INPUT DROP [237324:104418063]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [311602:113967214]
:FTP - [0:0]
-A INPUT -i lo -j ACCEPT 
-A INPUT -p tcp -m tcp ! --tcp-flags FIN,SYN,RST,ACK SYN -m state --state NEW -j DROP 
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT 
-A INPUT -p tcp -m tcp --dport 22 -m state --state NEW -j ACCEPT 
-A INPUT -p tcp -m tcp --dport 80 -m state --state NEW -j ACCEPT 
....

具体内容并不重要,重要的是防火墙规则。如您所见,端口 22 和端口 80 已打开,因此添加一行以打开端口 6000;作为附加的安全措施,仅允许访问您的远程服务器:

-A INPUT -p tcp -m tcp --dport 6000 -s ip.of.remote.server/32 -m state --state NEW -j ACCEPT

然后重新启动您的机器或重新加载防火墙规则(service iptables restart)。

答案2

JvO 对 telnet 的看法完全正确:不要。SSH 在很多方面都更胜一筹,不仅仅是安全性,还包括处理转发和其他方面。

注意:RHEL 7 默认使用firewalld,而不是iptables。

尝试:

firewall-cmd --zone=public --list-all

查看您的设置。默认设置应该有效。

并确保:

grep -i X11Forwarding /etc/ssh/sshd_config

结果是‘是’。

尝试一下:

ssh -Y remote-server-address

然后:

xclock

(如果您已禁用 IPv6,或者想要了解更多详细信息,请参见此处:http://unix.stackexchange.com/a/225642/95470

相关内容