24/07 课后预习

  • 学习之初

&定位&设立自己的发展方向

&猿课三年有效期

&CentOS 7.3 系统, VMware 虚拟软件, X-shell &Putty 终端

&写博客: 记录学习的历程, 学习进程经验公开分享

&密码保存工具,KeePass, consolidate pwd, 对密码进行双重保护

&aminglinux 培训资源 r.aminglinux.com

&课程用的代码及命令 centos7.aminglinux.com

&Linux

Linux是一个操作系统, ios-unix, andriod-linux

Linux 版本以及二次开发

  • 安装虚拟机
  •  

,安装CentOS

Swap 2048M (Memory =1G)

8G (Max)

  • 配置IP 地址

编辑--虚拟网络编辑器

由于重启后,ip地址会变更,于是要变IP 为静态IP, 命令:

vi /etc/sysconfig/network-scripts/ifcfg-ens33 (to change the ip to static status)

进入网卡配置文件后

(i 编辑)BOOTPROTO---dhcp>>static onboot---no>>yes

(add) IPADDR=192.168.XXX.XXX NETMASK=255.255.255 GATEWAY=192.168.xxx.xxx DNS1=119.29.29.29 (全部更改好后 :wq保存退出)

更改后重启网络服务: systemctl restart network.service.

Step brief:

dhclient

ip add

vi /etc/sysconfig/network-scripts/ifcfg-ens33 (to change the ip to static status)

bootproto----static

onboot---yes

&网络问题排查(ip配置后网卡不能上网)

1.如果nat模式ping不通,试试桥接 (右下角--设置)

dhclient -r (由于已经运行了dhclient,所以用-r 命令取消之前的dhchient)

dhclient

ifconfig(ip 会变化)

通过win+R 输入命令cmd 看到本地连接地址,当时用桥接模式时,要保证桥接ip与主机ip为同一个网段,因为workstation和主机连接同一个交换,处于同一个网段

再次确认是否处于连接状态

2.换回NAT 模式,在NAT 的模式下排查

移除网络vmnet8 重新添加(IP会变 dhclient-r 后重新添加ip)

查询网关(如果网络通是应该有网关的)

note. 如果没有ifconfig命令,用yam命令进行安装 yum install -y ip net-tools

&Putty 配置

输入IP 编辑名字>> save

windows 窗口回滚 决定上翻页数

&Xshell连接

通过工具>>选项设置邮件黏贴

如多窗口运行时,可点窗口选择窗口分布

&密钥认证

1. putty 密钥认证

puttygen>>生成密钥对>>保存公钥私钥

linux 操作

进入编辑模式,黏贴公钥

保存后,关闭防火墙 setenforce 0

回到putty配置,载入ip认证(auth),load secrect key

秘钥的好处:更加复杂,不易破解

命令简化:

mkdir /root/.ssh

chmod 700 /root/.ssh

vi /root/.ssh/autorized_key

close selinux firewall ----setenforce 0

SSH AUTH

&Xshell秘钥设置

工具>>主机秘钥管理者>>新建用户密钥生成向导

生成秘钥,同理配置linux

在秘钥编辑里#继续添加Xshell公钥

返回X-shell属性设置密钥认证,便可不输入密码直接进入

&单用户模式

如果忘记密码,进入单用户模式更改密码

重启linux: reboot, init6, shutdown -r now

e to edit 进入grab页面(找到你系统中的启动盘)(此种方法grub未加密)

update as below (rw init=/sysroot/bin/sh )

切换回系统

此后要切换语言至英文因为vmware不识别中文 LANG=en, 之后再passwd root

最后记得最后一步,关于selinux的操作,否则会导致无法登录:touch /.autorelabel

Step brief:

1.reboot

2.grub)ro ----rw init=/sysroot/bin/sh

3.Ctrl+x 进入安全模式

4. /sysroot/ swich back to original system

5.passwd root

6.LANG=en

7.passwd root

8.touch /.autorelabel

&run level

0-6 ,0单用户模式,2-4多用户模式,5图形操作界面,6 reboot

如果grab有密码,无法进入单用户模式,用光盘或系统u盘重新进入装系统的页面下(重启加载光驱)

更改密码后设置里关闭光盘启动

  • 克隆&多机互联

Clone

Manage -clone (init 0)

Revise IP Adr: vi /etc/sysconfig/network-scripts/ifcfg-ens33

Change address and delete UUID

*please make sure the copied the copied station is closed, otherwise the new copy one will be affected 

Change Hostname; hostnamectl set-hostname fred-02

Multipul Linux stations connect

Connect with others: ssh ipadr/ ssh username@ip/ ssh -p(port) 22 [email protected]

Connect by Public keys:

ssh -keygen(generate public/private keys)

cat /root/.ssh/id_rsa.pub (get public key)

copy the pub key to another station

vi /root/.ssh/authorized_key (update the Pub key in another station)

setenforce 0

Notes: Public Key: /root/.ssh/id_rsa.pub Private Key: /root/.ssh/id_rsa

猜你喜欢

转载自blog.csdn.net/nongfuchui/article/details/81217479