操作步驟:

1.準備條件,服務器需求安裝有rdesktop(且文件在目錄/usr/loca/bin下面)、用戶使用帳戶pc開頭、遠程登陸windows 10.86.1.35(NLB IP)

2.準備登陸腳本

cat /temp/rdp.sh

#!/bin/bash

sleep 3 #必須使用sleep,值是1也行,否則進入桌面後腳本會在後臺運行

SUNRAYUSER=`whoami|sed 's/pc//'`

/usr/local/bin/rdesktop -f -a 16 -u$SUNRAYUSER -p xxx -d mitacad 10.86.1.35

3.啟動桌面後自動啟動項先都會讀取公共目錄,/usr/share/gnome/autostart ;再讀取本機目錄~/.config/autostart;我們只需在公共目錄添加文件並將腳本自啟動

[root@rhelsunray1 ~]# cat/usr/share/gnome/autostart/rdp.sh.desktop

[Desktop Entry]

Name=无名称

Encoding=UTF-8

Version=1.0

Exec=/temp/rdp.sh

X-GNOME-Autostart-enabled=true

[root@rhelsunray1 ~]# chmod o+rx/usr/share/gnome/autostart/rdp.sh.desktop