栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

Centos带来的幸福

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Centos带来的幸福

  1. 换Yum源
    1. 1提权

[usera@centos79 yum.repos.d]$     sudo   -i

[sudo] usera 的密码:   // 输入的密码不显示 Pwd@123.com

[root@centos79 ~]#

  1. 2备份(阿里开源镜像站)

[root@centos79 ~]    mv    /etc/yum.repos.d/CentOS-Base.repo    /etc/yum.repos.d/CentOS-Base.repo.backup

[root@centos79 ~]#   cd   /etc/yum.repos.d/

[root@centos79 yum.repos.d]#    ls

  1. 3下载新的配置文件

[root@centos79 yum.repos.d]#  wget -O /etc/yum.repos.d/CentOS-Base.repo  https://mirrors.aliyun.com/repo/Centos-7.repo

[root@centos79 yum.repos.d]# ls

     2   .SSH

  2.1查看是否已经安装openssh

[root@centos79 yum.repos.d]# yum   list   installed    |   grep   openssh

openssh.x86_64                              7.4p1-21.el7               @anaconda

openssh-clients.x86_64                      7.4p1-21.el7               @anaconda

openssh-server.x86_64                       7.4p1-21.el7               @anaconda

[root@centos79 yum.repos.d]# cd   /etc/ssh

[root@centos79 ssh]# ls

moduli       ssh_host_ecdsa_key      ssh_host_ed25519_key.pub

ssh_config   ssh_host_ecdsa_key.pub  ssh_host_rsa_key

sshd_config  ssh_host_ed25519_key    ssh_host_rsa_key.pub

[root@centos79 ssh]# cat   sshd_config

** 默认已经安装了,如果没有安装,需要yum   install    openssh-server   进行安装

    2.2   查看sshd是否正在运行

[root@centos79 ssh]# ps   -e   |   grep   sshd

  1442 ?        00:00:00 sshd

或者[root@centos79 ssh]# systemctl   status   sshd

  2.3  使用Windows中的FinalShell连接CentOS的sshd

桌面运行FinalShell,先这样,再那样,就好了。

[root@centos79 ssh]# cp   sshd_config   sshd_config.bak

[root@centos79 ssh]# vim   sshd_config

找到PasswordAuthentication yes ,把前面的 # 号去掉,开启使用用户名密码来作为连接验证;修改无误后输入 :wq 回车,保存退出

修改配置文件后要重启服务

[root@centos79 ssh]# systemctl   restart    sshd

[root@centos79 ssh]# systemctl   status    sshd

桌面运行FinalShell,先这样,再那样,真的就好了。

  3 .Vsftpd

  3.1安装vsftpd

[root@centos79 ~]#    yum  install    -y    vsftpd

完毕!

[root@centos79 ~]#     systemctl    start   vsftpd

[root@centos79 ~]#    systemctl    status   vsftpd

   Active: active (running) since 二 2022-05-17 10:49:42 CST; 13s ago

[root@centos79 ~]#    ifconfig

ens33: flags=4163  mtu 1500

        inet 192.168.231.128

 

     3.2vsftpd实现下载

 [root@centos79 ~]# firewall-config         //  打开防火墙配置项

打钩,勾选ftp

[root@centos79 ~]# cd    /var/ftp

[root@centos79 ftp]# ls

pub

[root@centos79 ftp]# mkdir    new

[root@centos79 ftp]# ls

new  pub

[root@centos79 ftp]# ll

总用量 0

drwxr-xr-x. 2 root root 6 5月  17 11:05 new      // 注意,这里的权限没有w

drwxr-xr-x. 2 root root 6 6月  10 2021 pub

[root@centos79 ftp]#

到此为止,windows可以访问linux中的ftp服务器了。

[root@centos79 ftp]# ll

总用量 0

drwxr-xr-x. 2 root root 6 5月  17 11:05 new

drwxr-xr-x. 2 root root 6 6月  10 2021 pub

[root@centos79 ftp]# cd  new

[root@centos79 new]# ls

[root@centos79 new]# echo  "123"   >   ./a.txt

[root@centos79 new]# cat   ./a.txt

123

[root@centos79 new]#

在window中可以下载文件a.txt了

但是不能上传文件。

​​​​​​​  3.3  改配置文件,实现上传

[root@centos79 new]#   cd   /etc/vsftpd

[root@centos79 vsftpd]#   ls

ftpusers  user_list  vsftpd.conf  vsftpd_conf_migrate.sh

[root@centos79 vsftpd]#    vim  vsftpd.conf             :set nu  29行 删除一个字符#        anon_upload_enable=YES

[root@centos79 vsftpd]#    systemctl  restart     vsftpd

[root@centos79 vsftpd]# cd  /var/ftp

[root@centos79 ftp]# ll

总用量 0

drwxr-xr-x. 2 root root 19 5月  17 11:18 new

drwxr-xr-x. 2 root root  6 6月  10 2021 pub

[root@centos79 ftp]# chmod  o+w  ./new

[root@centos79 ftp]# ll

总用量 0

drwxr-xrwx. 2 root root 19 5月  17 11:18 new

drwxr-xr-x. 2 root root  6 6月  10 2021 pub

[root@centos79 ftp]#   setenforce    0

[root@centos79 ftp]#

​​​​​​​  3.4  改配置文件,实现删除文件,新建文件夹

[root@centos79 new]#   cd   /etc/vsftpd

[root@centos79 vsftpd]# ls

ftpusers  user_list  vsftpd.conf  vsftpd_conf_migrate.sh

[root@centos79 vsftpd]# vim  vsftpd.conf  

anon_mkdir_write_enable=YES                    33

anon_other_write_enable=YES   // 自己添加       34

[root@centos79 vsftpd]#   systemctl  restart vsftpd

​​​​​​​  3.5  改配置文件,实现上传的文件能下载

anon_umask=022

[root@centos79 vsftpd]# systemctl  restart vsftpd       35

    4  httpd 

       4.1  安装httpd

[root@centos79 vsftpd]#   yum   install  -y   httpd

[root@centos79 vsftpd]#  systemctl   start    httpd

[root@centos79 vsftpd]#   systemctl   status    httpd

[root@centos79 ~]# firewall-config    // http打个勾

此时应该可以从windows访问Linux中的web服务器

[root@RH-00 html]#   cd   /var/www/html

[root@RH-00 html]# echo "hello!  Apache"  >  ./index.html

再次从windows访问Linux中的web服务器,看下主页是否发生变化。

​​​​​​​          4.2    改配置文件,实现虚拟主机

[root@RH-00 conf]#  cd    /etc/httpd/conf

[root@RH-00 conf]# ls

httpd.conf  magic

[root@RH-00 conf]# cat   httpd.conf

[root@RH-00 conf]# vim  /etc/httpd/conf/httpd.conf    // 改配置文件

(:set nu     :42)

#Listen 12.34.56.78:80

Listen 80

Listen 8055                 //新加一行  42

。。。。。。。。。。

       //新加3行  114

DocumentRoot   "/var/www/html2"

#

# DocumentRoot: The directory out of which you will serve your

# documents. By default, all requests are taken from this directory, but

# symbolic links and aliases may be used to point to other locations.

#

DocumentRoot "/var/www/html"

(:wq)

 重启服务systemctl  restart  httpd

在vsftpd里加anon_root=/var/www   并重启

[root@centos79 conf]# firewall-config   处理8055端口,新加一个端口

[root@centos79 conf]# cd /var/www

[root@centos79 www]# mkdir html2

[root@centos79 www]# ls

cgi-bin  html  html2

[root@centos79 www]# cd  html2

[root@centos79 html2]# echo "This is my second website" > index.html

[root@centos79 html2]# ls

index.html

[root@centos79 html2]#

   5   .配置ftp访问的路径到http默认目录

 [root@centos79 vsftpd]# vim vsftpd.conf             25   anon_root=/var/www

[root@centos79 vsftpd]# systemctl  restart vsftpd

[root@centos79 vsftpd]# cd /var/www

[root@centos79 www]# ll

总用量 0

drwxr-xr-x. 2 root root  6 3月  24 22:58 cgi-bin

drwxr-xr-x. 2 root root 24 5月  25 16:55 html

drwxr-xr-x. 2 root root 24 5月  25 17:01 html2

[root@centos79 www]# chmod o+w ./html2

[root@centos79 www]#

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/941588.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号