來源:http://blog.csdn.net/u010355144/article/details/45541107
命令行方式:telnet,ssh(客戶端可以用putty、SecureCRT、SSH Secure Shell Client等SSH 客戶端軟件,輸入您服務器的IP地址,並且輸入登錄的用戶和密碼就可以登錄了。我常選擇的客戶端軟件是putty。)
圖像用戶界面:vnc,
1.ubuntu 下telnet服務安裝配置 另參見具體設置
下面我們來對Ubuntu Linux telnet的安裝和設置進行一下講解。首先我們需要加載telnet的服務,之后對於root等有關方面進行設置。
在Windows系統中,telnet的配置相對簡單一些。
那么在Ubuntu Linux中的telnet的設置就相對比較麻煩了。不少朋友都對這個安裝過程不熟悉。沒有關系,這里我們就來對Ubuntu Linux telnet的安裝設置進行一下講解。
1. sudo apt-get install xinetd telnetd
2. Ubuntu Linux telnet安裝后,系統也會有相應提示:
sudo vi /etc/inetd.conf並加入以下一行(沒有這個文件就會新建一個,沒關系的,下同)
telnet stream tcp nowait telnetd /usr/sbin/tcpd /usr/sbin/in.telnetd
3. sudo vi /etc/xinetd.conf並加入以下內容進行下一步的Ubuntu Linux telnet設置:
# Simple configuration file for xinetd
#
# Some defaults, and include /etc/xinetd.d/
defaults
{
# Please note that you need a log_type line to be able to use log_on_success
# and log_on_failure. The default is the following :
# log_type = SYSLOG daemon info
instances = 60
log_type = SYSLOG authpriv
log_on_success = HOST PID
log_on_failure = HOST
cps = 25 30
}
includedir /etc/xinetd.d
4. sudo vi /etc/xinetd.d/telnet並加入以下內容:
# default: on
# description: The telnet server serves telnet sessions; it uses
# unencrypted username/password pairs for authentication.
service telnet
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
}
5. 重啟機器或重啟網絡服務sudo /etc/init.d/xinetd restart
6. 使用telnet客戶端遠程登錄即可進行非root用戶訪問.
7.使用root登錄:
mv /etc/securetty /etc/securetty.bak 這樣root可以登錄了.也可這樣:
修改/etc/pam.d/login這個文件.只需將下面一行注釋掉即可.
#auth required lib/security/pam_securetty.so
8. Ubuntu Linux telnet的詳細配制/etc/xinetd.d/telnet
編輯推薦
TCP/IP協議專題
TCP/IP(傳輸入控制地議/網際協議)是一種網絡通信協議,它規范了網絡上的所有通信設備,尤其是一個主機與..
文章摘要:下面我們來對Ubuntu Linux telnet的安裝和設置進行一下講解。首先我們需要加載telnet的服務,之后對於root等有關方面進行設置。
service telnet
{
disable =no
bind =192.168.1.2
only_from=192.168.1.0/24
#上面這兩行說明僅提供內部網段!
Instance =UNLIMITED
Nice =0
Flags =REUSE
socket_type=stream
wait =no
user =root
#server =/usr/sbin/telnetd
server =/usr/sbin/in.telnetd
server_args =-a none
log_on_failure +=USERID
}
service telnet
{
disable =no
bind =140.116.142.196
only_from=140.116.0.0/16
no_access=140.116.32.
#上面三行設置外部較為嚴格的限制
instance =10
umask =022
nice =10
flags =REUSE
socket_type=stream
wait =no
user =root
#server =/usr/sbin/telnetd
server =/usr/sbin/in.telnetd
log_on_failure +=USERID
}
9.加設防火牆iptables:
如果想要針對192.168.0.0/24這個網段及61.xxx.xxx.xxx這個IP進行telnet開放,可以增加下面幾行規則:
/sbin/iptables -A INPUT -p tcp -i eth0 -s 192.168.0.0/24 --dport 23 -j ACCEPT
/sbin/iptables -A INPUT -p tcp -i eth0 -s 61.xxx.xxx.xxx --dport 23 -j ACCEPT
/sbin/iptables -A INPUT -p tcp -i eth0 --dport 23 -j DROP
10.Ubuntu Linux telnet最后一項設置,加設防火牆/etc/hosts.allow(deny)機制:
上面開放了192.168.0.0/24這個網段,但是如果您只想讓其中的192.168.0.1~192.168.0.5進入,可以設置如下 :
vi /etc/hosts.allow
in.telnetd:192.168.0.1,192.168.0.2,192.168.0.3,192.168.0.4,192.168.0.5:allow
轉自:http://blog.csdn.net/zjf280441589/article/details/17408991
引言:
Linux大多應用於服務器,而服務器不可能像PC一樣躺在辦公室里,它們是放在IDC機房的,所以我們平時登錄Linux系統都是通過遠程登錄的。Linux系統中是通過ssh服務實現的遠程登錄功能。默認ssh服務開啟了22端口(telnet是23端口),而且當我們安裝完系統時,這個服務已經安裝,並且是開機啟動的。所以不需要我們額外配置什么就能直接遠程登錄linux系統。Ssh服務的配置文件為/etc/ssh/sshd_config,你可以修改這個配置文件來實現你想要的ssh服務。比如你可以更改啟動端口為36000.
為什么不用Telnet?telnet因為采用明文傳送報文,安全性不好,很多Linux服務器都不開放telnet服務,而改用更安全的ssh方式了。
1、ssh的安裝
sudoapt-get install ssh
2、生成密鑰
ssh-keygen
中間過程會提示你存放密鑰的地方Enterfile in which to save the key (/home/gavin/.ssh/id_rsa):我們選擇默認,直接回車;
然后會提示Enterpassphrase (empty for no passphrase):設置一個進入私鑰的密碼,在后邊導入id_rsa到puttygen會用到,設置一個自己容易記又不會讓人輕易破解的就可以了;
上述過程執行完畢后會生成兩個文件,一個是id_rsa(私鑰),一個是id_rsa.pub(公鑰);
這里將公鑰改名為authorized_keys:
cd .ssh
mv id_rsa.pub authorized_keys
3、修改配置文件(/etc/ssh/sshd_config)
sudo vim /etc/ssh/sshd_config
其中有這么一行#AuthorizedKeysFile %h/.ssh/authorized_keys,把前面的#去掉即可;
4、到windows平台將先前生成的私鑰id_rsa,轉換成putty所識別的格式(*.ppk),得到文件id_rsa.ppk.
(1)把linux上生成的id_rsa拷貝到windows平台下;
(2)下載puttygen.exe,(http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html)然后打開,我們要讓它幫我們做個通行證,生成id_rsa.ppk;
詳細步驟:
a)選擇“load”,載入以保存好的私鑰文件:
b)彈出的對話框里把“文件類型”換成“所有文件”然后選中我們從ubuntu服務器上生成的id_rsa文件;
c)接着,它會提示你輸入密碼,這不是你linux用戶密碼,而是前面下划線上的私鑰密碼;
d)其他的選項直接默認就好了,設置完成之后,點擊"saveprivate key",注意(格式為*.ppk)因為putty只識別自己做的鑰匙;
(注意:這個文件名字就直接用id_rsa.ppk就可以了,不要再改了)
5、windows上啟動putty,進行如下配置
(1)Session-Logging-Hostname:填上你的linux的IP地址
(附:在Linux上用ifconfig命令獲取,內容是inet之后的那一串數字)
(2)Windows-Translation-在下拉菜單里選上UTF-8。
(這兒軟件一般默認的就是UTF-8,不過最好還是確認一下,如果不是的話,登錄后將會出現中文亂碼)
(3)Connection-Data - Auto login username:填上你登錄Linux時用的用戶名。
(4)Connection-SSH-Auth Private key file for authentication:選上id_rsa.ppk;
然后點擊open,按照提示輸入私鑰密碼即可訪問。
附:密鑰認證機制遠程登錄linux
SSH服務支持一種安全認證機制,即密鑰認證。所謂的密鑰認證,實際上是使用一對加密字符串,一個稱為公鑰(publickey),任何人都可以看到其內容,用於加密;另一個稱為密鑰(privatekey),只有擁有者才能看到,用於解密。通過公鑰加密過的密文使用密鑰可以輕松解密,但根據公鑰來猜測密鑰卻十分困難。ssh的密鑰認證就是使用了這一特性。服務器和客戶端都各自擁有自己的公鑰和密鑰。
2.Ubuntu上VNC 配置.
一)利用VNC實現Windows遠程訪問Linux服務器小結(包括對虛擬機的遠程訪問+fedora 12)
一、vnc view訪問在vmw虛擬機上的linux
Linux服務器架設在VMware之上的虛擬機,那么可以直接使用VMware自帶的vnc,而不用自己安裝,只要在VMware的設置中將遠程顯示的選項打開,指定一個端口和密碼就可以了,如下圖所示:

再在windows中下載vnc veiw 地址為http://www.realvnc.com/products/free/4.1/winvncviewer.html
使用即可。
點擊下載好的vnc-4_1_3-x86_win32_viewer.exe輸入宿主機器的IP:桌面號或IP:5900+桌面號

在vnc veiw中輸入在虛擬機設置的密碼

點擊OK成功后顯示如下所示

到此 windows通過vnc訪問在宿主機器虛擬機上的linux(fedora)完成。
二、vnc veiw訪問在linux(非通過虛擬機)
vnc的安裝和使用
我的環境是被控端 fedora 12 ,主控端 win xp
1、下載vnc server、vnc view
vnc server 下載地址:http://www.realvnc.com/cgi-bin/download.cgi

vnc view 下載地址 :http://www.realvnc.com/products/free/4.1/winvncviewer.html

2、安裝
在linux 下安裝
[root@fengge lijing]# rpm -i /home/lijing/Soft/vnc-4_1_3-x86_linux.rpm
可能提示以下錯誤
/Soft/compat-libstdc++-296-2.96-141.i386.rpm: Header V3 DSA signature: NOKEY, key ID 4ebfc273
這是因為缺乏依賴包的原因,那么下載compat-libstdc++-296-2.96-141.i386.rpm
下載地址:
安裝compat-libstdc++-296-2.96-141.i386.rpm后再安裝vnc server
[root@fengge lijing]# rpm -i /home/lijing/Soft/compat-libstdc++-296-2.96-141.i386.rpm --force --nodeps
warning: /home/lijing/Soft/compat-libstdc++-296-2.96-141.i386.rpm: Header V3 DSA signature: NOKEY, key ID 4ebfc273
[root@fengge lijing]# rpm -i /home/lijing/Soft/vnc-4_1_3-x86_linux.rpm
Checking for perl... [OK]
Checking for uname... [OK]
Checking for xauth... [OK]
3、執行vncserver命令:
[root@fengge lijing]# vncserver
You will require a password to access your desktops.
Password: --輸入密碼
Verify: 登錄vncserver密碼
New 'fengge:1 (lijing)' desktop is fengge:1 注意這邊的1,為桌面編號(即顯示號)
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/fengge:1.log
4、在win運行vnc view (192.168.8.169:1或192.168.8.169:5901都是可以的,但192.168.8.169:5901不行(會出現connection refused的錯誤))

點擊OK后即可登錄。
三、vnc使用及注意事項
1、vnc view登錄時提示 unable to connect to host:Connection refused(10061)
那么要設置被控機linux的遠程桌面及防火牆

防火牆可以添加vnc的端口或直接關閉。

2、設置VNC的連接密碼。
#vncpasswd (輸入VNC連接密碼)
注:如果你現在不設置密碼,當你用vncserver啟動vnc服務時會提示你設置密碼。
3、啟動VNC服務。
#vncserver (啟動vnc服務器)
4、關閉VNC服務。
#vncserver -kill :1 (關閉VNC服務器)
注意:kill和:1之間有一個空格。1與上面的對應
5、啟動 停止 重啟
#service vncserver start/stop/restart
二)Ubuntu下vnc4server
Ubuntu下設置VNCServer(有vnc4server和vncserver本文以vnc4server講解)
export XKL_XMODMAP_DISABLE=1 可以注釋掉
# unset SESSION_MANAGER 可以注釋掉
# exec /etc/X11/xinit/xinitrc 必須注釋掉這個,這個是解決灰屏+鼠標變X號的關鍵
unset DBUS_SESSION_BUS_ADDRESS 可以注釋掉(有時候注釋掉,會出現灰屏+鼠標變X號)
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup Ubuntu上沒有/etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources Ubuntu上沒有$HOME/.Xresources
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & 可以不要
gnome-panel & 任務欄等bar在桌面上 !!!
gnome-settings-daemon & 感覺沒啥用呢
x-window-manager & 窗口管理器
nautilus & 文件管理器(但是不會出現任務欄等bar在桌面上) 可以不要,可以通過gnome-panel上的Places入口調出。
gnome-terminal & 不是一種x-terminal-emulator 所以不可以省略(gnome-terminal.wrapper,這個才是一種x-terminal-emulator) 可以不要,可以通過右鍵桌面出來的菜單Open Terminal來調出。
7、修改/etc/X11/xinit/xinitrc文件的許可權限,使其可執行:
sudo chmod 755 /etc/X11/xinit/xinitrc
8、啟動vnc4server: (這邊必須要重啟(因為之前的被我們在第4步給關了),第6步才能生效)
vnc4server
注意:記住此處冒號后提示的數字
vncserver -geometry 1600x970 可以改變分辨率,不然不大的一塊區域。(且區域啟動后,好像就不好修改了)
vncserver -geometry 1280x1024 -depth 24 -cc 4 24位深,4為真彩
9、用windows電腦登錄VNC
方法一: 使用vnc viewer登錄這台服務器: http://www.realvnc.com/下載 (這個可行)
在VNC viewer中中輸入: ip地址:桌面號 (注意桌面號是開啟vnc時返回的那個數字(第8步)) 或 ip地址:端口號 (注意端口號是開啟vnc時返回的那個數字(第8步).其實這個數字加上5900作為端口號),點擊連接. (注意桌面號或端口號一定要)
在TightVNC中,只能輸入ip地址:端口號
在按照提示輸入你在第三部輸入的vncserver的密碼,成功進入遠程桌面。
方法二:打開遠程桌面連接
選擇"sesman-Xvnc"-->輸入"用戶名和密碼"(ubuntu用戶的密碼)-->回車,成功登錄到Ubuntu 14.04桌面,現在可以進行遠程操作了。(應該這個不行吧!?)
或者
選擇 選擇"vnc-any"-->輸入"Ip地址和密碼"(vncserver的密碼)-->回車,成功登錄到Ubuntu 14.04桌面,現在可以進行遠程操作了。
10、若前面執行失敗導致在VNC下看不到圖形界面,鼠標變成"X"形狀,請查看第七條是否執行過,同時將剛建過的VNCServer刪掉,vncserver -kill :1(1代表前面啟動的vncserver序號)
11、Ubuntu 10.10下增添了對Windows鍵的定義,在里面被定義為Super鍵,當用戶在VNC下按下字母"d"時,會被錯誤的當做返回桌面的快捷方式導致d無法被輸入,此時可修改快捷鍵方式來避免此bug,新打開一個終端,在里面輸入:gconf-editor,這樣會彈出一個對話框,到“Apps->Metacity->Global keybingdings"中找“show desktop”,將其默認值<Super>D改為<Ctl><Alt>D即可。
轉載:http://www.cnblogs.com/ljjphysics/archive/2011/09/13/2175005.html
注:
問題一 vnc使用及注意事項
1、vnc view登錄時提示 unable to connect to host:Connection refused(10061)
那么要設置被控機linux的遠程桌面及防火牆 在http://blog.csdn.net/weivs929/article/details/6218624
防火牆可以添加vnc的端口或直接關閉。
3.Ubuntu上rdp配置(不同於VNC方式).
一、安裝Xrdp
Windows遠程桌面使用的是RDP協議,所以ubuntu上就要先安裝Xrdp,在ubuntu軟件中心搜索xrdp安裝。
安裝xrdp的同時會自動安裝vnc4server,xbase-clients組件
或者終端命令行輸入安裝: sudo apt-get install xrdp vnc4server xbase-clients
二、配置xrdp設置
需要通過xrdp連接到桌面,需要正確配置相關信息並填充到.xsession文件(針對每個用戶)或/etc/startwm.sh(針對所有用戶),輸入如下命令
echo unity>~/.xsession
或者
sudo sed -i.bak '/fi/a #xrdp multi-users \n unity \n' /etc/xrdp/startwm.sh
三、安裝xfce4
$sudo apt-get install xfce4
或者
sudo apt-get install xubuntu-desktop 這個軟件比較大,總計需要260M。
四、配置xfce4
echo "xfce4-session" >~/.xsession
創建.xsession文件並寫入內容。
這樣之后,網上很多做法就已經結束了,但是我使用遠程桌面連接mstsc.exe連接的時候,僅僅顯示connecting to sesman ip127.0.0.1之后就沒有反映了,應該繼續連接ok才對。這樣,繼續:
繼續配置xfce4
sudo vi /etc/xrdp/startwm.sh
在. /etc/X11/Xsession前一行插入xfce4-session
或
sudo vim /etc/xrdp/startwm.sh 把最下面的test和exec兩行注釋掉,添加一行 gnome-session
重新啟動xrdp
sudo service xrdp restart
五、windows下無法通過VNC客戶端軟件遠程連接Ubuntu14.04的桌面解決方法:
VNC客戶端不支持加密。任何連接到遠程桌面共享服務器的嘗試都將導致No matching security types錯誤。也是靠這邊的把 require encrytion 關閉 來解決的。
1、安裝dconf-editor
sudo apt-get install dconf-editor
2、運行dconf-editor調整(注意一定要當前用戶來運行,不能加sudo),並訪問如下配置路徑
$dconf-editor
org > gnome > desktop > remote-access ->require encrytion 關閉

或
dconf write /org/gnome/desktop/remote-access/require-encryption false
或
dbus-launch --exit-with-session dconf write /org/gnome/desktop/remote-access/require-encryption false 在上面那條不能用於ssh的情況下 跟下面的命令效果一樣。
或
gsettings set org.gnome.Vino require-encryption false 跟上面的命令效果一樣。 可用於Ubuntu 推薦!
GLib-GIO-Message: 10:19:43.137: Using the 'memory' GSettings backend. Your settings will not be saved or shared with other applications.
可以先執行
export GIO_EXTRA_MODULES=/usr/lib/x86_64-linux-gnu/gio/modules/然后再執行。
確認已禁用遠程服務器上的加密
$ gsettings list-recursively org.gnome.Vino | grep encrypt
參見:https://www.jianshu.com/p/65f19e1c20d9 Ubuntu18.04.2LTS配置vnc+frp內網穿透實現桌面遠程訪問
或
使用tunnel 隧道技術來進行加密存取 這個我沒試成功?
3、/usr/lib/vino/vino-server --sm-disable start
4、see "settings --> sharing" again
六、vino-server方式的配置(跟vnc方式不同)
在/usr/share/applications目錄下打開”桌面共享”(即 desktop sharing)選項,進一步設定
桌面共享選項中首先要開啟共享,關於是否允許其他用戶控制,遠程連接時是否需要本機確認,遠程連接的密碼等項目根據需要自己設定。如果需要從公網即外部網絡訪問此ubuntu計算機,需要開啟”自動配置UPnP路由器開放和轉發端口項目”(這個在fedora 12中是“ 配置網絡為自動接受連接”)。
選項“你必須確認任何對該計算機的訪問”來手動確認每個遠程連接。另外,另一個有用的安全特性是通過選項“需要用戶輸入密碼”創建一個確定的共享密碼。這樣當用戶每次想要訪問你的桌面時需要知道並輸入密碼。
一般建議如下圖:
如果是13.04的話,以上已經完成設置了.
或
settings-> Sharing->Screen Sharing:設置:

或
Ubuntu在命令行開啟遠程桌面 (在終端執行下列三個命令即可) 推薦!
gsettings set org.gnome.Vino enabled true 允許其他人查看您的桌面
gsettings set org.gnome.Vino view-only false 允許其他用戶控制您的桌面
gsettings set org.gnome.Vino prompt-enabled false 關閉對本機器的每次訪問進行確認
gsettings set org.gnome.Vino authentication-methods ['vnc'] 如果選中Require the user to enter this password,則修改為 org.gnome.Vino authentication-methods ['vnc'] 且會修改org.gnome.Vino vnc-password 'keyring'中的keyring為一個加密的東西
gsettings set org.gnome.Vino vnc-password 'keyring' 這個怎么設置??
gsettings set org.gnome.Vino use-upnp true 用於如果需要從公網即外部網絡訪問此ubuntu計算機
gsettings set org.gnome.Vino require-encryption false 等同於dbus-launch --exit-with-session dconf write /org/gnome/desktop/remote-access/require-encryption false
重啟Ubuntu:
sudo reboot
七、啟動VNCServer服務
sudo vncserver
或
/etc/init.d/vncserver
八、連接
方法1)xvnc方式 (但是,不需要開vnc4server) (我這種成功了!!!)
可以使用端口5900(這種都不需要安裝vnc4server的,在Ubuntu上自帶VINO(即自帶的Desktop Sharing Preferences)) 這種最推薦,看到的也是最像本地操作的窗口。
也可以自定義,例如5901(用於開vnc4server的時候) 是本地操作的窗口的一個子集
在windows電腦上我們打開遠程桌面,輸入ubuntu電腦的IP地址,會出現如下畫面,Module項目選擇使用的協議,這里選擇vnc-any,輸入IP地址,端口不變(5900),你設定的密碼,即可遠程連接到ubuntu 14.04桌面,如下圖:
此方法不需要再安裝一個xface的桌面。
填寫
在本機搜索remmina,點擊NEW新建一個連接 , Protocol中選中VNC-Virtual Network Computing。
server中填寫要連接的ip地址(ip地址端口5900),userName和password中分別填寫連接的用戶名和密碼。
點擊連接即可。
注意,要確保連接的機器是可以連接的。可以在桌面共享(Desktop Sharing)中進行配置

4.排錯
# ps -ef | grep vnc
root 17330 1 0 16:18 pts/19 00:00:00 Xvnc4 :1 -desktop SPRITE-LINUX2:1 (root) -auth /root/.Xauthority -geometry 1280x1024 -depth 24 -rfbwait 30000 -rfbauth /root/.vnc/passwd -rfbport 5901 -pn -fp /usr/X11R6/lib/X11/fonts/Type1/,/usr/X11R6/lib/X11/fonts/Speedo/,/usr/X11R6/lib/X11/fonts/misc/,/usr/X11R6/lib/X11/fonts/75dpi/,/usr/X11R6/lib/X11/fonts/100dpi/,/usr/share/fonts/X11/misc/,/usr/share/fonts/X11/Type1/,/usr/share/fonts/X11/75dpi/,/usr/share/fonts/X11/100dpi/ -co /etc/X11/rgb -cc 4
關於灰屏+鼠標變X號:
因為vncserver找不到指定的圖形化軟件 例如nautilus等
0)這個可行的
# Uncomment the following two lines for normal desktop:
export XKL_XMODMAP_DISABLE=1
unset DBUS_SESSION_BUS_ADDRESS
#unset SESSION_MANAGER
#exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
#xsetroot -solid grey
#vncconfig -iconic &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#xterm -bg wheat -sb -sl 4096 -geometry 100x24+0+0 -rightbar -fn "-misc-fixed-medium-r-normal--13-120-75-75-c-80-iso8859-1" -e `pwd`/console.sh &
gnome-panel &
gnome-settings-daemon &
x-window-manager &
#gnome-session &
nautilus &
gnome-terminal &
1)
sudo update-alternatives --all
通過查找vnc關鍵字,查到:
There is only one alternative in link group vncconfig (providing /usr/bin/vncconfig): /usr/bin/vnc4config
Nothing to configure.
There are 2 choices for the alternative vncpasswd (providing /usr/bin/vncpasswd).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/vnc4passwd 75 auto mode
1 /usr/bin/tightvncpasswd 70 manual mode
2 /usr/bin/vnc4passwd 75 manual mode
There are 2 choices for the alternative vncserver (providing /usr/bin/vncserver).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/tightvncserver 70 auto mode
1 /usr/bin/tightvncserver 70 manual mode
2 /usr/bin/vnc4server 65 manual mode
There is only one alternative in link group x0vncserver (providing /usr/bin/x0vncserver): /usr/bin/x0vnc4server
Nothing to configure.
There are 2 choices for the alternative Xvnc (providing /usr/bin/Xvnc).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/Xvnc4 75 auto mode
1 /usr/bin/Xtightvnc 70 manual mode
2 /usr/bin/Xvnc4 75 manual mode
紅色部分是出問題的地方,因為另個vncserver打架了。刪掉一個就行啦,sudo apt purge tightvncserver
2).重新啟動下電腦,試一試。我就是各種配置之后,始終黑屏,重啟電腦后OK。
3).sudo chmod a+x /etc/X11/xinit/xinitrc 在Ubuntu上有這個文件
這也是種辦法,不知是否是這句話生效了
並確認/root/.vnc/xstartup是一個可執行文件,要確認是否有x權限
4)如果Linux本地端已經啟用Gnome或KDE圖形環境,當VNC客戶端連接服務器后,可能會只顯示灰屏,沒有正常啟用圖形環境。查看~/.vnc下的日志時會提示錯誤:You are already running a session manager。
這時需要去掉xstartup文件中的
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
這兩行前的#,再重啟vncserver。如果Linux本地端是init 3模式,則不需要修改這兩行。
5)
root@SPRITE-LINUX2:~# cat /root/.vnc/SPRITE-LINUX2:1.log 查看log文件,看看到底發生了什么錯誤 (這個是我的錯誤) 這種方法最好看到底哪里出問題了!!!
Xvnc Free Edition 4.1.1 - built Feb 25 2015 23:02:21
Copyright (C) 2002-2005 RealVNC Ltd.
See http://www.realvnc.com for information on VNC.
Underlying X server release 40300000, The XFree86 Project, Inc
Sun Dec 15 16:18:15 2019
vncext: VNC extension running!
vncext: Listening for VNC connections on port 5901
vncext: created VNC server for screen 0
error opening security policy file /etc/X11/xserver/SecurityPolicy 出現這個錯誤,無所謂。不影響vncserver
Could not init font path element /usr/X11R6/lib/X11/fonts/Type1/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/Speedo/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/misc/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/75dpi/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/100dpi/, removing from list!
Could not init font path element /usr/share/fonts/X11/75dpi/, removing from list!
Could not init font path element /usr/share/fonts/X11/100dpi/, removing from list!
字體問題
原因:vncserver默認尋找的X系統的字體路徑在/usr/X11R6/lib/X11/fonts/下,但RHEL5卻在/usr /share/X11/fonts/下,Ubuntu10.10卻在/usr/share/fonts/X11/下
解決:
方法1)
sudo apt-get install xvfb xfonts-100dpi xfonts-75dpi xfonts-cyrillic xorg dbus-x11
這個其實就是xfonts-100dpi xfonts-75dpi起了作用,但是只能把最后兩條warning去掉。但是還是不能見到界面。
或
$sudo apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal
方法2)
RHEL5:
mkdir /usr/X11R6/lib
cd /usr/X11R6/lib
ln -s /usr/share/X11 X11
Ubuntu:
mkdir /usr/X11R6/lib/X11/
cd /usr/X11R6/lib/X11
ln -s /usr/share/fonts/X11/ fonts
6)
解決:
#yum grouplist
已加載插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com 已安裝環境分組: GNOME 桌面 可用的環境分組: 最小安裝 基礎設施服務器 計算節點 文件及打印服務器 基本網頁服務器 虛擬化主機 帶 GUI 的服務器 KDE Plasma Workspaces 開發及生成工作站 可用組: 傳統 UNIX 兼容性 兼容性程序庫 圖形管理工具 安全性工具 開發工具 控制台互聯網工具 智能卡支持 科學記數法支持 系統管理 系統管理工具 完成
安裝GNOME桌面:
yum groupinstall "GNOME 桌面"
安裝完成后
init 5
防火牆設置開放
iptables -I INPUT -p tcp --dport 5901 -j ACCEPT 客戶端方式
iptables -I INPUT -p tcp --dport 5801 -j ACCEPT 瀏覽器方式
/etc/init.d/iptable save

