实验内容参考

文章详细描述了如何在Linux系统中禁用root登录、使用密码和密钥对进行验证登录、文件操作(包括scp和sftp)、在Windows上使用Xshell、以及配置tcpwrappers限制远程访问。实验包括创建用户、设置SSH安全选项、密钥对验证和防火墙规则的应用。
摘要由CSDN通过智能技术生成

实验要求

1.禁止root登录,禁用dns反向查询

2.使用zhangsan/密码,可以从192.168.1.2登录远程服务器192.168.1.1 

3.客户端wangwu使用密钥对,用zhangsan登录服务器

4.客户端用户wangwuzhangsan的身份向远程服务器上传文件test.txt

5.禁止192.168.1.10远程登录linux主机的sshd服务

6.使用sftp将本机的456文件上传到远程主机

7.在win7安装xshell,并登录远程服务器,并实现文件的上传与下载

实验步骤

实验一:使用密码验证登录,并练习文件操作

1.禁止root登录,禁用dns反向查询

#vim   /etc/ssh/sshd_config

PermitRootLogin  no   //此行默认存在,将yes改成no

UseDNS no            //需要添加

#systemctl  restart sshd

2.使用zhangsan/密码,从192.168.1.2登录远程服务器192.168.1.1

1)先192.168.1.1上创建用户zhangsan

#useradd   zhangsan

#passwd    zhangsan

2)在192.168.1.2上登录192.168.1.1

[root@localhost ~]# ssh  zhangsan@192.168.1.1

[zhangsan@localhost ~]$

3.利用scp命令,从客户端向远程服务器上传文件test.txt

[zhangsan@localhost ~]$ exit   --退到客户机

[root@localhost ~]# touch test.txt

[root@localhost ~]# scp test.txt zhangsan@192.168.1.1:/home/zhangsan

4. 登录服务器,查看是否上传成功

[root@localhost ~]# ssh  zhangsan@192.168.1.1

[zhangsan@localhost ~]$ll

5.将服务器/tmp/test1.txt文件下载到客户机

#在服务器的/tmp目录下创建一个测试文件

[zhangsan@localhost ~]$touch  /tmp/test1.txt  

[zhangsan@localhost ~]$ exit    --退到客户机

[root@localhost ~]# scp  zhangsan@192.168.1.1:/tmp/test1.txt  /tmp   #下载

[root@localhost ~]#ll  /tmp  --查看客户机/tmp下是否下载了文件

6.使用sftp将本机的456文件上传到远程主机

[root@localhost ~]#touch  456

[root@localhost ~]#sftp  zhangsan@192.168.1.1

Sftp>put  456

7.在windows7上安装xshell6

8.在windows客户机上登录linux服务器

实验一:使用密码验证登录,并练习文件操作

1.禁止root登录,禁用dns反向查询

#vim   /etc/ssh/sshd_config

PermitRootLogin  no   //此行默认存在,将yes改成no

UseDNS no            //需要添加

#systemctl  restart sshd

2.使用zhangsan/密码,从192.168.1.2登录远程服务器192.168.1.1

1)先192.168.1.1上创建用户zhangsan

#useradd   zhangsan

#passwd    zhangsan

2)在192.168.1.2上登录192.168.1.1

[root@localhost ~]# ssh  zhangsan@192.168.1.1

[zhangsan@localhost ~]$

3.利用scp命令,从客户端向远程服务器上传文件test.txt

[zhangsan@localhost ~]$ exit   --退到客户机

[root@localhost ~]# touch test.txt

[root@localhost ~]# scp test.txt zhangsan@192.168.1.1:/home/zhangsan

4. 登录服务器,查看是否上传成功

[root@localhost ~]# ssh  zhangsan@192.168.1.1

[zhangsan@localhost ~]$ll

5.将服务器/tmp/test1.txt文件下载到客户机

#在服务器的/tmp目录下创建一个测试文件

[zhangsan@localhost ~]$touch  /tmp/test1.txt  

[zhangsan@localhost ~]$ exit    --退到客户机

[root@localhost ~]# scp  zhangsan@192.168.1.1:/tmp/test1.txt  /tmp   #下载

[root@localhost ~]#ll  /tmp  --查看客户机/tmp下是否下载了文件

6.使用sftp将本机的456文件上传到远程主机

[root@localhost ~]#touch  456

[root@localhost ~]#sftp  zhangsan@192.168.1.1

Sftp>put  456

7.在windows7上安装xshell6

8.在windows客户机上登录linux服务器

实验一:使用密码验证登录,并练习文件操作

1.禁止root登录,禁用dns反向查询

#vim   /etc/ssh/sshd_config

PermitRootLogin  no   //此行默认存在,将yes改成no

UseDNS no            //需要添加

#systemctl  restart sshd

2.使用zhangsan/密码,从192.168.1.2登录远程服务器192.168.1.1

1)先192.168.1.1上创建用户zhangsan

#useradd   zhangsan

#passwd    zhangsan

2)在192.168.1.2上登录192.168.1.1

[root@localhost ~]# ssh  zhangsan@192.168.1.1

[zhangsan@localhost ~]$

3.利用scp命令,从客户端向远程服务器上传文件test.txt

[zhangsan@localhost ~]$ exit   --退到客户机

[root@localhost ~]# touch test.txt

[root@localhost ~]# scp test.txt zhangsan@192.168.1.1:/home/zhangsan

4. 登录服务器,查看是否上传成功

[root@localhost ~]# ssh  zhangsan@192.168.1.1

[zhangsan@localhost ~]$ll

5.将服务器/tmp/test1.txt文件下载到客户机

#在服务器的/tmp目录下创建一个测试文件

[zhangsan@localhost ~]$touch  /tmp/test1.txt  

[zhangsan@localhost ~]$ exit    --退到客户机

[root@localhost ~]# scp  zhangsan@192.168.1.1:/tmp/test1.txt  /tmp   #下载

[root@localhost ~]#ll  /tmp  --查看客户机/tmp下是否下载了文件

6.使用sftp将本机的456文件上传到远程主机

[root@localhost ~]#touch  456

[root@localhost ~]#sftp  zhangsan@192.168.1.1

Sftp>put  456

7.在windows7上安装xshell6

8.在windows户机上登录linux服务器

9.在windows客户机桌面上创建一个文件test3.txt,并利用rz命令将其上传到服务器

10.将服务器上的文件下载到客户机

1)先在服务器上创建一个测试文件test4.txt

2)利用sz下载

在服务器创建一个文件test4.txt

[zhangsan@localhost ~]$echo  “aaaa”  >test4.txt

实验二:使用密钥对登录linux

1. 客户端wangwu使用密钥对,用zhangsan登录服务器

 [root@localhost ~]# useradd wangwu

[root@localhost ~]# passwd wangwu

2.切换到wangwu

[root@localhost ~]# su   -   wangwu

3.创建密钥对

[wangwu@localhost ~]$ ssh-keygen  -t   ecdsa

4.将密钥对上传到192.168.1.1

[wangwu@localhost ~]$ ssh-copy-id -i  ~/.ssh/id_ecdsa.pub zhangsan@192.168.1.1

5.验证免密码登录

[wangwu@localhost ~]$ ssh   zhangsan@192.168.1.1

6.客户端用户wangwuzhangsan的身份向远程服务器上传文件test.txt

[zhangsan@localhost ~]$ exit

[wangwu@localhost ~]$ touch test.txt

[wangwu@localhost ~]$ scp test.txt zhangsan@192.168.1.1:/home/zhangsan

实验三:  练习tcpwrappers

1、服务器允许root登录

2、只允许192.168.1.2远程管理服务器

参考实验:

一、先给服务器设置一个主机名,以区分客户机与服务器

#vim   /etc/hostname

#reboot

二、修改服务器的ssh配置,允许root登录

#vim  /etc/ssh/sshd_config

#systemctl  restart  sshd

二 、设置服务器ssh免密登录(以root登录)

1、在客户机上为root用户创建密钥对

2、将root公钥上传到服务器的root公钥库里

3、在客户机验证免密登录服务器

三、在服务器上配置tcpwrappers策略,只允许192.168.1.2远程登录服务器

#vim  /etc/hosts.allow

#vim  /etc/hosts.deny

四、在客户机上测试远程登录

1、在192.168.1.2上可以远程登录

登录成功

2、将客户机地址临时改成192.168.1.3

然后在改ip地址

3、再次登录服务器失败

  • 26
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值