第八天笔记

一、nodejs环境下创建vue项目

1.使⽤yum安装了nodejs环境

# 安装epel
yum -y install epel-release
# 查找nodejs
yum list | grep nodejs
yum -y install nodejs.x86_64
# 验证(查看nodejs版本)
node -v

2.安装npm,设置镜像

# 安装npm包管理器
yum -y install npm
# 查看npm版本
npm -v
# 设置国内镜像
npm config set registry <https://registry.npmmirror.com>

3.使⽤npm安装了vue

npm install -g @vue/cli
# 查看vue版本
vue -V

4.使⽤安装vue软件,创建vue项⽬ vue create vuehtml000

vue create vuehtml1000

5.跳到项⽬⽬录中,npm run serve启动项⽬

cd vuehtml1000/
npm run serve
6.npm run build 构建项⽬ 7.将构建的项⽬⽬录dist⽬录中的所有⽂件部署到nginx的html⽬录中

cp -r ./dist/ /usr/share/nginx/html

8.nginx -s reload

二、搭建SSH服务

SSH两种认证⽅式

1、基于⽤户名密码的认证

[root@MissHou ~]# ssh 192.168.10.171 The authenticity of host '192.168.10.171 (192.168.10.171)' can't be established. RSA key fingerprint is 9f:71:de:3c:86:25:dd:f0:06:78:ab:ba:96:5a:e4:95. Are you sure you want to continue connecting (yes/no)? 提示信息:⽆法确认主机192.168.10.171的真实性,指纹 是 9f:71:de:3c:86:25:dd:f0:06:78:ab:ba:96:5a:e4:95. ,你确定想要继续吗?

2、基于密钥对的认证 基于密钥对认证,也就是所谓的免密码登录,理解免密登录原理:

远程管理SSH服务

1.安装ssh服务

由于当前的系统已经默认安装了openssh 1、关闭防⽕墙与SELinux(不关SElinux导致sshd的端⼝ ⽆法修改)

# 关闭firewalld防⽕墙
# 临时关闭
systemctl stop firewalld
 # 关闭开机⾃启动
systemctl disable firewalld
 # 关闭selinux
 # 临时关闭
setenforce 0
 # 修改配置⽂件  永久关闭
vim /etc/selinux/config
 SELINUX=disabled

2、配置yum源 JumpServer配置外⽹YUM源 => 阿⾥云

 # mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS
Base.repo.backup
 # wget -O /etc/yum.repos.d/CentOS-Base.repo 
<https://mirrors.aliyun.com/repo/Centos-7.repo>
 # yum clean all
 # yum makecache 

3、获取openssh⽣成的⽂件列表

# rpm -ql openssh-server
 # 配置⽂件
/etc/ssh/sshd_config              =>      ssh服务的主配置⽂件
/etc/sysconfig/sshd
 # 服务管理脚本
/usr/lib/systemd/system/sshd.service    =>      systemctl start sshd
 # ⽂件共享服务 提供⽂件上传下载的服务
/usr/libexec/openssh/sftp-server
 # ⼆进制⽂件程序⽂件
/usr/sbin/sshd
 # 公钥⽣成⼯具
/usr/sbin/sshd-keygen
 # man⼿册
/usr/share/man/man5/sshd_config.5.gz
 /usr/share/man/man8/sftp-server.8.gz
 /usr/share/man/man8/sshd.8.gz
  # rpm -ql openssh-clients
 # 客户端配置⽂件
/etc/ssh/ssh_config
 # 远程copy命令 服务器间进⾏⽂件传输
/usr/bin/scp
 # sftp客户端  上传下载⽂件操作
/usr/bin/sftp
 /usr/bin/slogin
 /usr/bin/ssh
 /usr/bin/ssh-add
 /usr/bin/ssh-agent
 /usr/bin/ssh-copy-id
 /usr/bin/ssh-keyscan
 # 客户端man⼿册
/usr/share/man/man1/scp.1.gz
 /usr/share/man/man1/sftp.1.gz
 /usr/share/man/man1/slogin.1.gz
 /usr/share/man/man1/ssh-add.1.gz
 /usr/share/man/man1/ssh-agent.1.gz
 /usr/share/man/man1/ssh-copy-id.1.gz
 /usr/share/man/man1/ssh-keyscan.1.gz
 /usr/share/man/man1/ssh.1.gz
 /usr/share/man/man5/ssh_config.5.gz
 /usr/share/man/man8/ssh-pkcs11-helper.8.gz

4、查看并修改ssh服务端的配置⽂件

# vim /etc/ssh/sshd_config
 38⾏ PermitRootLogin no
# 在配置⽂件设置permitRootlogin no,不允许root账户远程登录可以设置其他账户远程登录。
# vim /etc/ssh/sshd_config
 17⾏ Port 9999
# 更改SSH默认端⼝

5、sshd服务管理

# systemctl restart sshd  =>   重启
# systemctl status sshd   =>   状态
# systemctl stop sshd   =>   停⽌
# systemctl start sshd    =>   启动
# systemctl enable sshd   =>   开机⾃启动
# systemctl disable sshd  =>   开机不⾃启
# ps -ef |grep sshd     =>   进程

# netstat -tnlp |grep sshd  =>   端⼝

# ss -naltp |grep sshd

6、SSH客户端不验证指纹

# vim /etc/ssh/ssh_config
 35⾏ StrictHostKeyChecking no

7、⽤专业⼯具pwgen

⽣成⽤户密码 在实际⽣产环境中,其⽤户密码⼀定不要⼿⼯设置,建议使⽤专业的密码⽣成⼯具如pwgen。 ① 安装随机密码⽣成⼯具pwgen ② 使⽤pwgen⼯具⽣成随机密码 ③ 给账号code设置密码

第⼀步:创建code开发者账号

useradd code

第⼆步:配置EPEL源,安装pwgen⼯具

wget -O /etc/yum.repos.d/epel.repo

http://mirrors.aliyun.com/repo/epel-7.repo

yum clean all

yum makecache

第三步:安装pwgen密码⽣成⼯具

yum install pwgen -y

第四步:使⽤pwgen⽣成随机密码

pwgen -cnBs1 10 1

扩展:pwgen密码⽣成器的使⽤

pwgen --help

⽤法: pwgen 选项参数 ⻓度 ⽣成个数

Usage: pwgen [ OPTIONS ] [ pw_length ] [ num_pw ]

密码中⾄少包含⼀个⼤写字⺟-c or –capitalize

密码中不包含⼤写字⺟-A or –no-capitalize

密码中⾄少包含⼀个数字-n or –numerals

密码中不包含数字-0 or –no-numerals

密码中⾄少包含⼀个特殊符号-y or –symbols

⽣成完全随机密码-s or –secure

密码中不包含歧义字符(例如1,l,O,0)-B or –ambiguous

使⽤SHA1 hash给定的⽂件作为⼀个随机种⼦-H or –sha1=path/to/file[#seed]

在列中打印⽣成的密码-C

不要在列中打印⽣成的密码,即⼀⾏⼀个密码-1

不要使⽤任何元⾳,以避免偶然的脏话-v or –no-vowels

8、SSH免密登录

SSH免密的实现思路⼀共分为三个步骤(三步⾛)

第⼀步:在A主机针对某个账号(tom或jerry)⽣成公钥与私钥

第⼆步:使⽤某些⽅法把公钥发送到B主机中,然后追加到authorized_keys⽂件中

第三步:测试是否实现免密登录

1、① 在A主机针对某个账号⽣成公钥与私钥

ssh-keygen

② 使⽤ssh-copy-id把公钥⽂件中的内容传输到服务器端的~/.ssh/authorized_keys⽂件中

# ssh-copy-id code@11.1.1.100
 code@11.1.1.100's password:123456
③ 在JumpServer客户端测试免密登录是否成功

# ssh  code@11.1.1.100

2、① ⽣成公钥与私钥

# ssh-keygen
② 把id_rsa.pub⽂件,scp到RealServer服务器端

 # scp -P 3721 ~/.ssh/id_rsa.pub code@11.1.1.100:/home/code/
③ 在RealServer服务器端,把id_rsa.pub⽂件中的内容追加到~/.ssh/authorized_keys⽂件中

 # cd ~
 # cat id_rsa.pub >> ~/.ssh/authorized_keys
 # 权限
  RealServer:
~/.ssh : 700
 ~/.ssh/authorized_keys : 600
④ 测试免密是否成功

# ssh -p 3721 code@11.1.1.100

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值