Linux...第九章作业
2016-10-12 16:27
183 查看
<<<第九单元练习>>>
1.在desktop主机中建立用户westos,并设定其密码为westoslinux
2.配置desktop中的sshd服务要求如下:
*)设定sshd服务只允许westos用户可以被访问使用
*)创建westos用户的key认证方式
*)设定westos用户只允许使用key认证方式,屏蔽其系统密码认证方式
实验过程如下:
在服务器端的虚拟机下,创建用户westos 并设置密码
添加用户白名单,
#vim /etc/ssh/sshd_config
在100行位置更改系统文件
切换到客户端的虚拟机登录
重启sshd.service
#systemctl restart sshd.service
结果:
root登录失败,westos登录成功。
# ssh-keygen
生成公钥和私钥
查看文件
发送密钥给客户端
进入#vim /ect/ssh/sshd_config
重启sshd
删除authorzied_keys
再在客户端中登录,
1.ssh的key认证
#######生成key###########
[test@foundation0 ~]$ ssh-keygen ###生成公钥和私钥的工具
Generating public/private rsa key pair.
Enter file in which to save the key (/home/test/.ssh/id_rsa):『enter』 ###指定加密字符保存文件,使用默认
Created directory '/home/test/.ssh'.
Enter passphrase (empty for no passphrase): ###密码,必须大于4位
Enter same passphrase again:
Your identification has been saved in /home/test/.ssh/id_rsa.
Your public key has been saved in /home/test/.ssh/id_rsa.pub.
The key fingerprint is:###确认密码
a5:4f:02:51:68:59:f4:e8:e3:c5:91:1f:6f:86:99:06 test@foundation0.ilt.example.com
The key's randomart image is:
+--[ RSA 2048]----+
| .*+ |
| +. o . |
| .. . E . |
| o + + * |
| S + * + |
| . * . o |
| . . |
| |
| |
+-----------------+
[test@foundation0 .ssh]$ pwd
/home/test/.ssh###生成密钥存放位置
[test@foundation0 .ssh]$ ls
id_rsa id_rsa.pub####id_rsa位私钥,id_rsa.pub位公钥
#####################使用key加密目标主机的目标用户############
[test@foundation0 ~]$ ssh-copy-id -i /home/test/.ssh/id_rsa.pub westos@172.25.254.100
The authenticity of host '172.25.254.100 (172.25.254.100)' can't be established.
ECDSA key fingerprint is eb:24:0e:07:96:26:b1:04:c2:37:0c:78:2d:bc:b0:08.
Are you sure you want to continue connecting (yes/no)? yes
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
westos@172.25.254.100's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'westos@172.25.254.100'"
and check to make sure that only the key(s) you wanted were added.
ssh-copy-id####上传key的工具
-i####指定使用的公钥
/home/test/.ssh/id_rsa.pub#####使用公钥的名称
westos####被管理的目标用户
172.25.254.100####被管理用户所在主机的ip
authorized_keys###此文件在目标用户加目录的.ssh中,这个文件就是目标用户被加密的标识,文件内容位公钥内容。
2.sshd服务的简单配置
vim /etc/ssh/sshd_config###sshd服务的配置文件
48 PermitRootLogin yes|no###是否允许root用户通过sshd的认证
78 PasswordAuthentication yes|no###开启或关闭用户密码认证
AllowUsers student westos###用户白名单,只允许在名单中出现的用户使用sshd服务
systemctl restart sshd###从新加载配置
1.在desktop主机中建立用户westos,并设定其密码为westoslinux
2.配置desktop中的sshd服务要求如下:
*)设定sshd服务只允许westos用户可以被访问使用
*)创建westos用户的key认证方式
*)设定westos用户只允许使用key认证方式,屏蔽其系统密码认证方式
实验过程如下:
在服务器端的虚拟机下,创建用户westos 并设置密码
添加用户白名单,
#vim /etc/ssh/sshd_config
在100行位置更改系统文件
切换到客户端的虚拟机登录
重启sshd.service
#systemctl restart sshd.service
结果:
root登录失败,westos登录成功。
# ssh-keygen
生成公钥和私钥
查看文件
发送密钥给客户端
进入#vim /ect/ssh/sshd_config
重启sshd
删除authorzied_keys
再在客户端中登录,
1.ssh的key认证
#######生成key###########
[test@foundation0 ~]$ ssh-keygen ###生成公钥和私钥的工具
Generating public/private rsa key pair.
Enter file in which to save the key (/home/test/.ssh/id_rsa):『enter』 ###指定加密字符保存文件,使用默认
Created directory '/home/test/.ssh'.
Enter passphrase (empty for no passphrase): ###密码,必须大于4位
Enter same passphrase again:
Your identification has been saved in /home/test/.ssh/id_rsa.
Your public key has been saved in /home/test/.ssh/id_rsa.pub.
The key fingerprint is:###确认密码
a5:4f:02:51:68:59:f4:e8:e3:c5:91:1f:6f:86:99:06 test@foundation0.ilt.example.com
The key's randomart image is:
+--[ RSA 2048]----+
| .*+ |
| +. o . |
| .. . E . |
| o + + * |
| S + * + |
| . * . o |
| . . |
| |
| |
+-----------------+
[test@foundation0 .ssh]$ pwd
/home/test/.ssh###生成密钥存放位置
[test@foundation0 .ssh]$ ls
id_rsa id_rsa.pub####id_rsa位私钥,id_rsa.pub位公钥
#####################使用key加密目标主机的目标用户############
[test@foundation0 ~]$ ssh-copy-id -i /home/test/.ssh/id_rsa.pub westos@172.25.254.100
The authenticity of host '172.25.254.100 (172.25.254.100)' can't be established.
ECDSA key fingerprint is eb:24:0e:07:96:26:b1:04:c2:37:0c:78:2d:bc:b0:08.
Are you sure you want to continue connecting (yes/no)? yes
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
westos@172.25.254.100's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'westos@172.25.254.100'"
and check to make sure that only the key(s) you wanted were added.
ssh-copy-id####上传key的工具
-i####指定使用的公钥
/home/test/.ssh/id_rsa.pub#####使用公钥的名称
westos####被管理的目标用户
172.25.254.100####被管理用户所在主机的ip
authorized_keys###此文件在目标用户加目录的.ssh中,这个文件就是目标用户被加密的标识,文件内容位公钥内容。
2.sshd服务的简单配置
vim /etc/ssh/sshd_config###sshd服务的配置文件
48 PermitRootLogin yes|no###是否允许root用户通过sshd的认证
78 PasswordAuthentication yes|no###开启或关闭用户密码认证
AllowUsers student westos###用户白名单,只允许在名单中出现的用户使用sshd服务
systemctl restart sshd###从新加载配置
相关文章推荐
- Linux运维-第7周作业
- Linux作业7
- Linux作业(3)
- 马哥linux+python——2015年9月1日课程作业
- linux中的作业管理与进程管理
- 马哥2016全新Linux+Python高端运维班第一周作业
- linux运维实战练习-2016年1月19日-2月3日课程作业(练习)
- Linux运维笔记-课后作业-简单登陆与使用
- Linux-C基础知识学习:C语言作业-将5个学生成绩保存在一个数组中,单独实现一个计算平均成绩的average函数, 在main函数中获取该函数返回的平均值,并打印。
- LINUX作业( 四)
- megeedu Linux+Python高级运维班 3期 第四周作业
- [作业] 马哥2016全新Linux+Python高端运维班第二周作业
- linux最后一次作业题
- 马哥2016全新Linux+Python高端运维班第二周作业
- Linux与云计算——第二阶段Linux服务器架设 第九章:Mail电子邮件服务器架设—postfix和Dovecot
- 20155202 张旭 课下作业: Linux下IPC机制
- Linux系统下任务作业自动化执行工具--cron、 anacron、at、和 batch
- Linux进程查看与管理、作业控制、网络客户端工具
- Linux服务及安全管理第八周作业【Linux微职位】
- 马哥-51CTO-Linux培训中-作业2