現在公司要求服務器不允許上傳下載文件,也不允許複製之類的。領導說用VNC,然後查了一下,VNC是可以複製的(可以添加相關選項禁用複製功能),另外VNC賬號要使用LDAP認證還不是太方便。
後來找了一下,發現 xrdp 這個軟件。這個其實就是一個遠程桌面,在WIN下可以直接用 mstsc連接。
它支持LDAP認證。然後核心還是用的VNC。
因爲要禁用複製粘貼,然後默認這個是可以的。直接把
sesman/chansrv/clipboard.h
中定義的函數,在
sesman/chansrv/chansrv.c
中全部註釋即可。然後再編譯...
LDAP認證:
centos5、centos6 直接複製一下就OK
cp /etc/pam.d/system-auth-ac /etc/pam.d/xrdp-sesman
ubuntu:
vi /etc/pam.d/xrdp-sesman #%PAM-1.0 @include common-auth @include common-account @include common-session @include common-password
另外建議把 /etc/xrdp/xrdp.ini 中 其它配置刪除,僅使用 sesman-Xvnc
[globals] bitmap_cache=yes bitmap_compression=yes port=3389 crypt_level=low channel_code=1 max_bpp=24 #black=000000 #grey=d6d3ce #dark_grey=808080 #blue=08246b #dark_blue=08246b #white=ffffff #red=ff0000 #green=00ff00 #background=626c72 [xrdp1] name=sesman-Xvnc lib=libvnc.so username=ask password=ask ip=127.0.0.1 port=-1
還有iptables 相關設置。
#!/bin/bash # INIT CHAIN iptables -F iptables -X iptables -Z iptables -F -t nat iptables -X -t nat iptables -Z -t nat iptables -P INPUT DROP iptables -P OUTPUT DROP iptables -P FORWARD ACCEPT #INPUT CHAIN iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -m state --state ESTABLISHED -j ACCEPT # Docker Centos 6 ERROR "FATAL: Could not load /lib/modules/4.4.0-45-generic/modules.dep: No such file or directory" iptables -A INPUT -p tcp -m multiport --dport 22,3389 -m state --state NEW -j ACCEPT iptables -A INPUT -p udp -s 192.168.10.4 --sport 53 -j ACCEPT # DNS iptables -A INPUT -p udp -s 192.168.10.5 --sport 123 -j ACCEPT # NTPDATE iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT iptables -A INPUT -p icmp --icmp-type echo-reply -j ACCEPT #OUTPUT CHAIN iptables -A OUTPUT -m state --state ESTABLISHED -j ACCEPT iptables -A OUTPUT -p udp -d 192.168.10.4 --dport 53 -j ACCEPT # DNS iptables -A OUTPUT -p udp -d 192.168.10.5 --dport 123 -j ACCEPT # NTPDATE iptables -A OUTPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT # Xrdp iptables -A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT iptables -A OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT
上面的 -m multiport 在Docker Centos 6 中報錯,然後拆成,即可
iptables -A INPUT -p tcp --dport 3389 -m state --state NEW -j ACCEPT iptables -A INPUT -p tcp --dport 22 -m state --state NEW -j ACCEPT
SSH僅允許指定用戶或者組登錄:
vi /etc/ssh/sshd_config # add AllowUsers root test1 test2 AllowGroups root test1 test2
目前這樣測試OK。