文章目录
- 1, centos6安装vnc服务端
- vnc常用命令
- 设置vnc随机登录密码
- 设置ssh 密钥文件登录:禁止密码登录
- 2, ubuntu安装vnc服务端
- 3, windows 安装vncviewer客户端
1, centos6安装vnc服务端
# 1, install vncserver
yum -y install epel-release
yum -y install vnc-server# 2, 安装xfce桌面,安装中文输入法
# yum grouplist|grep -i xfce
yum -y groupinstall 'X Window system'
yum -y groupinstall Xfce
yum install "@Chinese Support"#3,启动vnc: 按照提示输入远程连接密码,允许端口转发
# 端口是根据命令指定的: vncserve :1--> 5901, vncserve:10-->5910
iptables -I INPUT -p tcp --dport 5901:5902 -j ACCEPT
iptables -I INPUT -p udp --dport 5901:5902 -j ACCEPT
service iptables save
vncservercat > ~/.vnc/xstartup<<EOF
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
startxfce4 &[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
EOF# 4,重启配置
vncserver -kill :1
vncserver
vnc常用命令
#1, 查看已创建的连接
[a@a ~]$ vncserver -list
TigerVNC server sessions:
X DISPLAY # PROCESS ID
:11 41496
:2 41915
:4 9389
:3 8731# 2, 断开连接
[a@a ~]$ vncserver -kill :3
Killing Xvnc process ID 8731
[a@a ~]$ vncserver -list
TigerVNC server sessions:
X DISPLAY # PROCESS ID
:13 41496
:5 41915
:4 9389# 3, 创建新的连接
[a@a ~]$ vncserver :6
New 'eadage:6 (yskj)' desktop is eadage:6
Starting applications specified in /home/yskj/.vnc/xstartup
Log file is /home/yskj/.vnc/eadage:6.log[a@a ~]$ vncserver -list
TigerVNC server sessions:
X DISPLAY # PROCESS ID
:13 41496
:5 41915
:6 55923
:4 9389
设置vnc随机登录密码
##设置vnc登录密码
vncpasswd
Password
verfiy:# 1, hash + datewang@controller:~$ date +%s |sha256sum |base64 |head -c 32 ;echo
MjFjOTRkOWFhNzA2YTUwZmQ1NjUyMTBk# 2, openssl 产生随机数
wang@controller:~$ openssl rand -base64 32
V6wuudtVzYX6+/1g/Ic39E7TFxfRd7439oQ+gKCQ/E0=# 3,系统随机数
wang@controller:~$ < /dev/urandom tr -dc .\*\?_A-Z-a-z-0-9 |head -c${1:-32};echo
?CTJ2zMn*QwVFkSlMVCcpI.kbZ5vOUjC
设置ssh 密钥文件登录:禁止密码登录
在服务器配置:(1,生成密钥; 2,配置ssh; 3, 下载私钥)
[root@host .ssh]$ chmod 600 authorized_keys
[root@host .ssh]$ chmod 700 ~/.ssh#边界ssh配置文件: /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
PermitRootLogin yes
PasswordAuthentication noservice sshd restart
在客户机测试登录服务器:
root@controller:~# ssh -i id_rsa 192.168.1.40
Last login: Tue Jun 11 13:42:44 2019 from 192.168.1.33
[root@cent6 ~]#
2, ubuntu安装vnc服务端
#1, 更换源
cd /etc/apt
cp sources.list sources.list.backcat >sources.list <<EOF
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
EOF# 2, 安装xfce4, terminator
apt-get install xfce4 terminator -y
apt-get install vnc4server -y#3,启动vnc: 按照提示输入远程连接密码
vncservercat > ~/.vnc/xstartup<<EOF
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
startxfce4 &[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
EOF# 4,重启配置
vncserver -kill :1
vncserver #wang@controller:~/.vnc$ vncserver
#New 'controller:3 (wang)' desktop is controller:3
#Starting applications specified in /home/wang/.vnc/xstartup
#Log file is /home/wang/.vnc/controller:3.log
3, windows 安装vncviewer客户端
软件下载:https://vnc-viewer.informer.com/download/#downloading
直接点击,运行: 输入要访问的ip:id号, 填写登录密码即可