VNC作为一种非常成熟使用方便的远程桌面系统,使用非常广泛
首先要注意在安装Redhat的时候要安装图形化界面GNU——KDE和FTP服务器
安装VNC的过程非常简单
1、首先将光盘放入光驱,观察光驱的挂载点,然后将本地的yum源指向光驱。
假设现在的光驱挂载点为 /run/media/alex/RHEL-7.2 Server.x86_64/,太长了所以我使用软连接把这个目录连接到了/opt/rhel下面(ln -s /run/media/alex/RHEL-7.2\ Server.x86_64/ /opt/rhel),那么现在需要在/etc/yum.repos.d/目录下建立一个新文件,rhel-source.repo,内容如下。
[base]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=file:///opt/rhel
enabled=1
gpgcheck=1
gpgkey=file:///opt/rhel/RPM-GPG-KEY-redhat-release
这个文件就指明了一个名为“base”的yum源,它指向光盘(并非光盘里面的Packages文件夹),使用baseurl=file...这种方式可以指向本地的文件。同时这里也可以支持http或者ftp格式,可以在局域网内搭建yum源服务器。
同时gpg证书也指向光盘中的gpg证书。注意如果光盘不是自动挂载的,或者你只有一个.iso文件,那么也可以把这个.iso文件上传到Redhat服务器上,然后使用mount -o loop xxx.iso的方式进行挂载。
配置完成之后刷新一下yum
yum clean all
yum update
如果配置的路径正确,那么此处会更新yum源,如果路径填写错误或者挂载出现问题,跑不了几行就会报ERROR
有了光盘的yum源之后再安装就轻而易举了,首先检查一下VNC是否被安装过了
rpm -qa vnc*
如果没有输出说明没有被安装过,那么我们现在就可以安装了
yum -y install vnc*
如果你之前yum配置的没有问题,那么此时安装应该是非常顺畅
依赖关系解决====================================================================================================================================================Package 架构 版本 源 大小
====================================================================================================================================================
正在安装:tigervnc x86_64 1.3.1-3.el7 base 210 ktigervnc-server x86_64 1.3.1-3.el7 base 202 k
为依赖而安装:fltk x86_64 1.3.0-13.el7 base 654 ktigervnc-icons noarch 1.3.1-3.el7 base 35 k事务概要
====================================================================================================================================================
安装 2 软件包 (+2 依赖软件包)总下载量:1.1 M
安装大小:2.6 M
vncpasswd
下面就可以启动VNC服务器了,注意当前命令行是哪个用户那么远程登录之后就是哪个用户,权限也是一致的
vncserver
每次执行都会新建一个vnc服务端,第一个使用5901端口,第二个5902以此类推。
windows做客户端的话,只需要安装一个VNCViewer,填入IP和端口,写上上面录入的密码就可以登录图形化界面
安装FTP不复杂,但是装FTP主要就是为了在SSH之外查看和修改服务器上的文件的,一般都会做成匿名访问,拥有很高的权限,可以查看,修改,删除任意一个服务器上的文件。主要任务就是修改配置文件/etc/vsftpd/vsftpd.conf,修改后如下
普通用户、root用户访问配置文件(推荐):
如果需要使用root用户密码登录,或者其他用户根据自己的权限登录,可以做如下配置
# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=No
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# The target log file can be vsftpd_log_file or xferlog_file.
# This depends on setting xferlog_std_format parameter
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# The name of log file when xferlog_enable=YES and xferlog_std_format=YES
# WARNING - changing this filename affects /etc/logrotate.d/vsftpd.log
#xferlog_file=/var/log/xferlog
#
# Switches between logging into vsftpd_log_file and xferlog_file files.
# NO writes to vsftpd_log_file, YES to xferlog_file
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
#chroot_local_user=YES
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
# sockets, you must run two copies of vsftpd with two configuration files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YESpam_service_name=vsftpd
userlist_enable=YES
userlist_deny=NO
tcp_wrappers=YES
local_root=/
chroot_local_user=YES
其中比较重要的有下面几项
1、让user_list文件生效,并只允许这个列表中的用户登录,并禁止匿名用户登录
userlist_enable=YES
userlist_deny=NO
anonymous_enable=NO
注意同时要将/etc/vsftpd/ftpuser文件里面的root删掉,因为ftpuser这个文件是个黑名单
2、设置用户登录后的默认目录,如果不修改默认是用户的HOME,但是这样在使用curl的时候容易出现550 Failed to change directory.的报错,如下
curl ftp://192.166.1.21/home/ -u admin:admin -v
* About to connect() to 192.168.1.2 port 21 (#0)
* Trying 192.168.1.2...
* Connected to 192.166.1.21 (192.166.1.21) port 21 (#0)
< 220 (vsFTPd 2.2.2)
> USER alex
< 331 Please specify the password.
> PASS 123456
< 230 Login successful.
> PWD
< 257 "/home/alex"
* Entry path is '/home/alex'
> CWD home
* ftp_perform ends with SECONDARY: 0
< 550 Failed to change directory.
* Server denied you to change to the given directory
* Connection #0 to host 192.166.1.21 left intact
curl: (9) Server denied you to change to the given directory
因为默认目录为home的话,那我如果在curl home就相当于/home/alex/home目录,是默认根目录的相对目录,所以我们为了方便需要把默认目录改成根目录/,方法如下
local_root=/chroot_local_user=YES
3、使用vsftpd直接监控21端口,而不是通过xinetd转发
LISTEN=YES
同时删除掉/etc/xinetd.d/下面和ftp有关的配置,但是如果你习惯于使用xinetd,那么就将LISTEN=YES注释掉,防止端口冲突,同时重启xinetd。
4、还有就是selinux导致的权限问题,上文说可以通过setenforce 0 来关闭selinux,但是这样可能会影响其他安全,但是如果不关闭selinux,就会报530 Login incorrect
curl ftp://192.168.1.21/home/admin/ -u admin:admin -s -v
* About to connect() to 192.168.1.2 port 21 (#0)
* Trying 192.168.1.2...
* Connected to 192.168.1.2 (192.168.1.2) port 21 (#0)
< 220 (vsFTPd 2.0.5)
> USER alex
< 331 Please specify the password.
> PASS alex
< 530 Login incorrect.
* Access denied: 530
* Closing connection 0
所以我们要有选择的关闭selinux,首先通过命令查看selinux里对ftp的限制
[root@localhost ~]# getsebool -a | grep ftpd
allow_ftpd_anon_write --> off
allow_ftpd_full_access --> off
allow_ftpd_use_cifs --> off
allow_ftpd_use_nfs --> off
ftpd_connect_db --> off
ftpd_use_passive_mode --> off
我们发现多数权限都是off状态,这里要开启一项就可以不用关闭selinux了,如下
[root@localhost ~]# setsebool -P allow_ftpd_full_access 1
[root@localhost ~]# getsebool -a | grep ftpd
allow_ftpd_anon_write --> off
allow_ftpd_full_access --> on
allow_ftpd_use_cifs --> off
allow_ftpd_use_nfs --> off
ftpd_connect_db --> off
匿名用户上传下载配置文件(风险高):
有些时候我们并不想搞得特别复杂,越简单越直接越好,最好匿名用户登录以后可以有像root一样的权限,随便下载删除文件,经常用在测试系统上。
# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=YESlocal_root=/
chroot_local_user=YES
anon_root=/#
# Uncomment this to allow local users to log in.
# When SELinux is enforcing check for SE bool ftp_home_dir
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
# When SELinux is enforcing check for SE bool allow_ftpd_anon_write, allow_ftpd_full_access
anon_upload_enable=YES
anon_world_readable_only=NO
anon_umask=022
anon_other_write_enable=YES#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
#xferlog_file=/var/log/xferlog
#
# If you want, you can have your log file in standard ftpd xferlog format.
# Note that the default log file location is /var/log/xferlog in this case.
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
# (Warning! chroot'ing can be very dangerous. If using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
#chroot_local_user=YES
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
# Make sure, that one of the listen options is commented !!
listen_ipv6=YESpam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
启动vsftpd的命令是:
service vsftpd restart
既然给了这么大的权限,所以干脆把selinux和防火墙也全都关掉。然后就可以自由的操作FTP了。
方法1:修改/etc/selinux/config文件中的SELINUX="" 为 disabled ,然后重启。
方法2:用命令setenforce 0,无需重启。(setenforce的格式:setenforce [ Enforcing | Permissive | 1 | 0 ])
如果你不想任何一个人通过浏览器就可以匿名访问你的FTP主机,那么可以加上下面两行,只允许除root以外的限定用户通过账号密码登录
userlist_deny=NO
userlist_file=/etc/vsftpd/user_list
然后你可以修改/etc/vsftpd/user_list来限定访问的用户,注意考虑/etc/vsftpd/ftpusers这个文件里面记录了黑名单。
最后要注意要对相应的要通过FTP传输的文件赋予相关访问权限。
比如如下三个文件:
-rw-------. 1 root root 126 9\u6708 12 18:39 ftpusers
-rw-------. 1 root root 366 9\u6708 12 18:41 user_list
-rw-------. 1 root root 5206 9\u6708 12 19:08 vsftpd.conf
-rwxr--rw-. 1 root root 338 8\u6708 3 2015 vsftpd_conf_migrate.sh
那么对于FTP用户来说,只能读取 vsftpd_conf_migrate.sh这一个文件,其余三个文件均无法读写。原因是
-rw------- 前三个是文件所有者的权限,中间三个是与文件所有者同组的权限,最后三位是其他用户的权限,FTP属于其他用户(如果你使用Linux的用户登录,那么要注意是否同组的问题),所以最后三位需要为rw-,一般执行如下命令
chmod o+r+w -R /xxx/xxx/*
意思就是对于其他用户(o)对某个目录下所有文件和递归后的文件,全部添加r和w权限,当然这样也是比较危险的。
另外RedHat安装完毕之后会自动打开防火墙,封锁除22以外的所有端口,所以还需要把防火墙暂时关闭
systemctl stop firewalld
永久关闭
systemctl disable firewalld
开启防火墙
systemctl enable firewalld