首页
常用命令
About Me
推荐
weibo
github
Search
1
linuxea:gitlab-ci之docker镜像质量品质报告
48,760 阅读
2
linuxea:如何复现查看docker run参数命令
19,489 阅读
3
Graylog收集文件日志实例
17,808 阅读
4
git+jenkins发布和回滚示例
17,364 阅读
5
linuxea:jenkins+pipeline+gitlab+ansible快速安装配置(1)
17,353 阅读
ops
Openvpn
Sys Basics
rsync
Mail
NFS
Other
Network
HeartBeat
server 08
Code
Awk
Shell
Python
Golang
virtualization
KVM
Docker
openstack
Xen
kubernetes
kubernetes-cni
Service Mesh
Data
Mariadb
PostgreSQL
MongoDB
Redis
MQ
Ceph
TimescaleDB
kafka
surveillance system
zabbix
ELK Stack
Open-Falcon
Prometheus
Web
apache
Tomcat
Nginx
自动化
Puppet
Ansible
saltstack
Proxy
HAproxy
Lvs
varnish
更多
音乐
影视
music
Internet Consulting
最后的净土
软件交付
持续集成
gitops
devops
登录
Search
标签搜索
kubernetes
docker
zabbix
Golang
mariadb
持续集成工具
白话容器
linux基础
nginx
elk
dockerfile
Gitlab-ci/cd
最后的净土
基础命令
jenkins
docker-compose
gitops
haproxy
saltstack
Istio
marksugar
累计撰写
675
篇文章
累计收到
140
条评论
首页
栏目
ops
Openvpn
Sys Basics
rsync
Mail
NFS
Other
Network
HeartBeat
server 08
Code
Awk
Shell
Python
Golang
virtualization
KVM
Docker
openstack
Xen
kubernetes
kubernetes-cni
Service Mesh
Data
Mariadb
PostgreSQL
MongoDB
Redis
MQ
Ceph
TimescaleDB
kafka
surveillance system
zabbix
ELK Stack
Open-Falcon
Prometheus
Web
apache
Tomcat
Nginx
自动化
Puppet
Ansible
saltstack
Proxy
HAproxy
Lvs
varnish
更多
音乐
影视
music
Internet Consulting
最后的净土
软件交付
持续集成
gitops
devops
页面
常用命令
About Me
推荐
weibo
github
搜索到
122
篇与
ops
的结果
2022-06-15
linuxea:curl常用命令
curl常用命令time_connect : 建立到服务器的 TCP 连接所用的时间time_starttransfer: 在发出请求之后,Web 服务器返回数据的第一个字节所用的时间time_total: 完成请求所用的时间在 发出请求之后,Web 服务器处理请求并开始发回数据所用的时间是(time_starttransfer)1.044 - (time_connect)0.244 = 0.8 秒客户机从服务器下载数据所用的时间是(time_total)2.672 - (time_starttransfer)1.044 = 1.682 秒指定特定主机IP地址访问网站 curl -x 61.1315.169.105:80 http://www.baidu.com curl -x 61.1315.169.125:80 http://www.baidu.com网页响应时间curl -o /dev/null -s -w "time_connect: %{time_connect}\ntime_starttransfer: %{time_starttransfer}\ntime_total: %{time_total}\n" "http://www.linuxea.com" time_connect: 0.009 time_starttransfer: 0.357 time_total: 0.358状态返回码curl -s -w %{http_code} "http://www.baidu.com"完成请求所用的时间curl -o /dev/null -s -w '%{time_total}' http://www.linuxea.com 0.456或者如下curl -o /dev/null -s -w "%{http_code}\n%{time_connect}\n%{time_starttransfer}\n%{time_total}" http://www.baidu.com 200 0.038 0.071 0.071文件创建一个新文件 curl-format.txt,然后粘贴: time_namelookup: %{time_namelookup}s\n time_connect: %{time_connect}s\n time_appconnect: %{time_appconnect}s\n time_pretransfer: %{time_pretransfer}s\n time_redirect: %{time_redirect}s\n time_starttransfer: %{time_starttransfer}s\n ----------\n time_total: %{time_total}s\n发出请求:curl -w "@curl-format.txt" -o /dev/null -s "http://wordpress.com/"或者在 Windows 上,它是... curl -w "@curl-format.txt" -o NUL -s "http://wordpress.com/"这是做什么的:-w "@curl-format.txt"告诉 cURL 使用我们的格式文件-o /dev/null将请求的输出重定向到 /dev/null-s 告诉 cURL 不要显示进度表"http://wordpress.com/"是我们请求的 URL。如果您的 URL 具有“&”查询字符串参数,请特别使用引号输出 time_namelookup: 0.001s time_connect: 0.037s time_appconnect: 0.000s time_pretransfer: 0.037s time_redirect: 0.000s time_starttransfer: 0.092s ---------- time_total: 0.164s制作 Linux/Mac 快捷方式(别名)alias curltime="curl -w \"@$HOME/.curl-format.txt\" -o /dev/null -s "然后你可以简单地调用...curltime wordpress.org
2022年06月15日
890 阅读
0 评论
0 点赞
2022-04-19
linuxea:winsw安装windows程序开机启动服务
在windows下也有需要开机启动的需求,而一些程序被打包后是没有做开机启动服务的。但是可以放在开机启动中或者计划任务中被不断的监制。这样的话就需要手动编写脚本完成。而更有友好的方式是将应用程序作为windown服务进行包装和管理,而在github上winsw项目致力于解决这个问题。要使用WinSw,至少需要三个文件WinSW.exe可执行程序NAME-service.xml 配置文件注明停止或者启动的参数和路径NAME-service.exe.config配置文件主要用做禁用对应用程序的 CAS 发布者策略的检查示例如下:nginx下载后,将WinSW-x64.exe放置当前目录,修改为nginx-service.exePS C:\nginx-1.21.1\nginx-1.21.1> dir 目录: C:\nginx-1.21.1\nginx-1.21.1 Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 2021/8/31 16:04 conf d----- 2021/8/31 16:04 contrib d----- 2021/8/31 16:04 docs d----- 2021/8/31 16:04 html d----- 2021/8/31 16:05 logs d----- 2021/8/31 16:05 temp -a---- 2021/8/31 16:26 17462251 nginx-service.exe ------ 2021/7/6 17:42 3752448 nginx.exe创建nginx-service.xml,内容如下<service> <id>nginx</id> <name>Nginx Service</name> <description>High Performance Nginx Service</description> <logpath>C:\nginx-1.21.1\nginx-1.21.1\logs</logpath> <log mode="roll-by-size"> <sizeThreshold>10240</sizeThreshold> <keepFiles>8</keepFiles> </log> <executable>C:\nginx-1.21.1\nginx-1.21.1\nginx.exe</executable> <startarguments>-p C:\nginx-1.21.1\nginx-1.21.1</startarguments> <stopexecutable>C:\nginx-1.21.1\nginx-1.21.1\nginx.exe</stopexecutable> <stoparguments>-p C:\nginx-1.21.1\nginx-1.21.1 -s stop</stoparguments> </service>创建nginx-service.exe.config文件,内容如下<configuration> <startup> <supportedRuntime version="v2.0.50727" /> <supportedRuntime version="v4.0" /> </startup> <runtime> <generatePublisherEvidence enabled="false"/> </runtime> </configuration>目录如下PS C:\nginx-1.21.1\nginx-1.21.1> dir 目录: C:\nginx-1.21.1\nginx-1.21.1 Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 2021/8/31 16:04 conf d----- 2021/8/31 16:04 contrib d----- 2021/8/31 16:04 docs d----- 2021/8/31 16:04 html d----- 2021/8/31 16:44 logs d----- 2021/8/31 16:05 temp -a---- 2021/8/31 16:26 17462251 nginx-service.exe -a---- 2021/8/31 16:37 266 nginx-service.exe.config -a---- 2021/8/31 16:36 650 nginx-service.xml ------ 2021/7/6 17:42 3752448 nginx.exe安装服务PS C:\nginx-1.21.1\nginx-1.21.1> .\nginx-service.exe install 2021-08-31 16:37:39,775 INFO - Installing service 'Nginx Service (nginx)'... 2021-08-31 16:37:39,811 INFO - Service 'Nginx Service (nginx)' was installed successfully.启动服务即可二进制程序go二进制传参数package main import ( "fmt" "net/http" "flag" ) func main() { var src string flag.StringVar(&src, "src", "", "source file") flag.Parse() flag.Usage() http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello, you've requested: %s,src=%s\n", r.URL.Path,src) }) http.ListenAndServe(":81", nil) }PS C:\Users\super\Desktop\mybook\windows-autostart\test> go build而后开始制作将WinSW-x64.exe放置当前目录,修改为web-flag-service.exeweb-flag-server.exe.config<configuration> <startup> <supportedRuntime version="v2.0.50727" /> <supportedRuntime version="v4.0" /> </startup> <runtime> <generatePublisherEvidence enabled="false"/> </runtime> </configuration>web-flag-service.xml <startarguments>-src "/data/wwwroot"</startarguments>的-src "/data/wwwroot"为参数<service> <id>web-flag</id> <name>web-flag</name> <description>This go test , name: web-flag</description> <logpath>C:\test\logs</logpath> <log mode="roll-by-size"> <sizeThreshold>10240</sizeThreshold> <keepFiles>8</keepFiles> </log> <executable>C:\test\web-flag.exe</executable> <startarguments>-src "/data/wwwroot"</startarguments> <stopexecutable>C:\test\web-flag.exe</stopexecutable> <stoparguments>-p C:\test</stoparguments> </service>最终的准备文件如下PS C:\test> dir 目录: C:\test Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 2021/8/31 18:06 logs -a---- 2021/8/31 16:37 266 web-flag-server.exe.config -a---- 2021/8/31 16:26 17462251 web-flag-service.exe -a---- 2021/8/31 18:13 550 web-flag-service.xml -a---- 2021/8/31 18:10 6003712 web-flag.exe安装PS C:\test> .\web-flag-service.exe install 2021-08-31 18:03:23,199 INFO - Installing service 'web-flag (web-flag)'... 2021-08-31 18:03:23,286 INFO - Service 'web-flag (web-flag)' was installed successfully.启动即可参考generatePublisherEvidencewinsw
2022年04月19日
962 阅读
0 评论
0 点赞
2022-04-17
linuxea:windows快速构建丝滑的ftpserver上传和下载
在windows中,可以使用smb来挂载目录,上篇linux上如何优雅的挂载windows smb有所记录,但是并非每个环境都会让你使用共享文件的协议,通常在一个注重安全的环境内,udp的这几个端口会被不由分说的禁用掉。因此就需要另外一个传输方式,比如ftp。通常,FPT作为server端被部署在linux环境下,但是有时候会被windows需要。也就是说需要在windows下部署ftp。但是类似与此类软件居多,如:serv-u, wftpserver,xlightftpd等。但是这些都太重,现在使用ftp server绿色版本搭建简易的ftp通道http://learning.happymmall.com/ftpserver/而后将ftp放行到防火墙端口当我们在linux上用ftp传输的时候不一定能否符合预期ftp是非常原始的传输工具,使用ftp客户端意味着你要手动创建一些目录或者,压缩你将传输的文件夹变成一个包或者一个文件。因此我们使用ncftp,你可以下载也可以使用yum安装ncftp参数-u:指定登录FTP服务器时使用的用户名; -p:指定登录FTP服务器时使用的密码; -P:如果FTP服务器没有使用默认的TCP协议的21端口,则使用此选项指定FTP服务器的端口号。 -m:在传之前尝试在目录位置创建目录(用于传目录的情况) -R:递规传子目录上传FTP将会在远程服务器创建FTP目录,test目录将会推送到FTP目录下ncftpput -u test -p test -P 21 -m -R 172.16.100.19 FTP ~/test/*下载ncftpget -u test -p test -P 21 -d ~/1.txt -R 172.16.100.19 . /FTPRush/test2而在windows客户端你可以使用一些支持ftp断点续传的工具,比如:FileZilla,sftp参考linux上如何优雅的挂载windows smb
2022年04月17日
987 阅读
0 评论
0 点赞
2022-04-17
linuxea:linux上如何优雅的挂载windows smb
在一些极端情况下,需要将一些备份推送到windows,或者从windows拉取到linux,假设没有吝啬的安全策略下,默认是可以的。但是这不安全,通常情况下,采用ftp更保险。但鉴于在内网运行,此操作可以被尝试。如果想尝试fpt,可以参考快速构建丝滑的ftpserver上传和下载首要条件创建用户mark创建组bakcupwindows 10windows10 运行appwiz.cpl -> 启动或关闭windows功能 -> 勾选SMB1.0/CIFS文件共享支持和SMB直通windws 2008windows 2008 r2添加nfs1,添加功能功能添加,下一步直到安装完成2,添加角色功能角色,下一步直到安装完成3,开启server服务重启服务器电脑。开始共享当我们安装了上面的角色和功能后,创建一个新的文件夹配置共享linux共享mount -t cifs //10.112.118.135/hainan_backups /data/Remotely_backup_data -o username=mark,password=DVjZTIwNDUzN,rwwindows server 20121.安装smb1, windows server的添加角色和功能向导,如下,选中"件服务器资源管理器"下一步直至安装结束。完证完成后重启服务器2.共享位置配置打开服务器管理 -> 文件和存储服务 -> 共享 -> 新建共享-> SMB共享-高级 在共享位置中选择输入自定义路径在E盘创建一个backups目录,并选中3.权限在权限中选择自定义权限并删除删除完成,选择添加按钮。这里添加一个mark用户,也可以是一个组因为是备份文件存放,我们需要对目录写入如法炮制,添加backup组而后修改共享权限报错Windows server 2012R2 设置文件共享目录报错:无法连接到C$管理共享已验证文件夹xxx在计算机xxx上是否存在Windows Remote Management(WinRM)查看端口PS C:\Users\Administrator> netstat -ano | findstr "445" TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4 TCP 192.168.29.27:57523 192.168.29.27:445 SYN_SENT 4 TCP [::]:445 [::]:0 LISTENING 4 TCP [fe80::dddf:c37a:79c6:afa6%12]:57532 [fe80::dddf:c37a:79c6:afa6%12]:445 SYN_SENT 4如果telnet不通0,检查下“网络和共享中心”→“高级共享设置”里有没有启用网络发现,有没有启用文件和打印机共享1,检查网卡连接是否勾选Microsoft网络客户端和Microsoft网络的文件和打印机共享2,运行输入“regedit”并点击确定以进入注册表编辑器。导航到这个位置(HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionPoliciesSystem),在右边空白处右击新建->DWORD(32位)值(D),将它命名为LocalAccountTokenFilterPolicy并且将它的数值数据改为1。重启您的计算机,然后检查问题是否解决。3,运行gpedit.msc,在“本地组策略编辑器”中选择“本地计算机策略”→计算机配置→Windows设置→安全设置→IP安全策略,在本地计算机。然后在右侧双击“新IP安全策略”,删掉“新IP筛选器列表”。检查服务是否开启Function Discovery Provider HostSSDP DiscoveryUPnP Device HostLanmanServer(server开启)白名单确保tcp 139和445已经放行UDP 137,138TCP 139,445,1354.挂载安装依赖cifs-utils 的包 cifs-utils avahi-libs cups-libs gnutls keyutils libldb libtalloc libtdb libtevent libwbclient nettle samba-client-libs samba-common samba-common-libs trousersyum localinstall *.rpm挂载mount -t cifs -o username=mark,password=DVjZTIwNDUzNm //10.100.163.119/backups /data/Remotely_backup_datamount -t cifs -o username=mark,password=DVjZTIwNDUzNm,vers=1.0 //10.100.163.119/backups /data/Remotely_backup_dataNov 3 11:08:44 localhost kernel: No dialect specified on mount. Default has changed to a more secure dialect, SMB2.1 or later (e.g. SMB3), from CIFS (SMB1). To use the less secure SMB1 dialect to access old servers which do not support SMB3 (or SMB2.1) specify vers=1.0 on mount.Nov 3 11:08:44 localhost kernel: Status code returned 0xc000006d STATUS_LOGON_FAILURENov 3 11:08:44 localhost kernel: CIFS VFS: Send error in SessSetup = -13Nov 3 11:08:44 localhost kernel: CIFS VFS: cifs_mount failed w/return code = -13查看[root@linuxea.com /home/sxxzx2019/smb]# ll /data/Remotely_backup_data/ 总用量 1 drwxr-xr-x 2 root root 0 7月 19 14:20 1 -rwxr-xr-x 1 root root 25 7月 19 13:59 test.txt.txt已经可以使用其他?https://www.tuxera.com/community/open-source-ntfs-3g/ https://github.com/tuxera/ntfs-3g/releases $ command tar xf ntfs-3g_ntfsprogs-2017.3.23.tgz cd ntfs-3g_ntfsprogs-2017.3.23 ./configure make make install mount -o username=mark//10.100.163.119/backups共享目录即可创建用户mark创建目录backups安全组权限共享文件权限123安装SMBmount error(112): Host is down Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)开启smb检测Enable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol Get-WindowsOptionalFeature -Online -FeatureName SMB1Protocol Disable-WindowsOptionalFeature -Online -FeatureName SMB1ProtocolSMB 服务器上 SMBv1检测Get-SmbServerConfiguration | Select EnableSMB1ProtocolPS C:\Users\Administrator> Get-SmbServerConfiguration | Select EnableSMB1Protocol EnableSMB1Protocol ------------------ True禁用Set-SmbServerConfiguration -EnableSMB1Protocol $false启用Set-SmbServerConfiguration -EnableSMB1Protocol $trueSMB 服务器上 SMB v2/v3检测:Get-SmbServerConfiguration | Select EnableSMB2Protocol禁用:Set-SmbServerConfiguration -EnableSMB2Protocol $false启用:Set-SmbServerConfiguration -EnableSMB2Protocol $true1PS C:\Users\Administrator> Enable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol Path : Online : True Restart Needed : FalsePS C:\Users\Administrator> Get-WindowsOptionalFeature -Online -FeatureName SMB1Protocol Feature Name : SMB1Protocol Display Name : SMB 1.0/CIFS 文件共享支持 Description : 支持 SMB 1.0/CIFS 文件共享协议和计算机浏览器协议。 Restart Required : Possible State : Enabled Custom Properties : ServerComponent\Description : 支持 SMB 1.0/CIFS 文件共享协议和计算机浏览器协议。 ServerComponent\DisplayName : SMB 1.0/CIFS 文件共享支持 ServerComponent\Id : 487 ServerComponent\Type : Feature ServerComponent\UniqueName : FS-SMB1 ServerComponent\Deploys\Update\Name : SMB1Protocol参考如何在 Windows 中检测、启用和禁用 SMBv1、SMBv2 和 SMBv3[[mount.cifs: mount error(112): Host is down]](https://serverfault.com/questions/830817/mount-cifs-mount-error112-host-is-down)what port or ports are used for File sharing in windows?Windows Server 2012 关闭445 135 139等端口安全设置快速构建丝滑的ftpserver上传和下载
2022年04月17日
980 阅读
0 评论
0 点赞
2022-04-02
linuxea:centos7.9使用trojan加速拉取代码
我们经常使用github或者其他的仓库,特别慢的时候,可以使用其他的浏览器插件来解决。但是,假设你已经购买了trojan,并且想在linux上使用,就可以考虑如下办法首先,在trojan下载一个版本即可,而后参考trojan的方式将配置文件导入到config.json中现在你有一个已经在页面生成好的配置文件,而后修改验证修改verify和verify_hostname为false,这在trojan的github上并没有得到解决,于是我们就不验证即可 "ssl": { "verify": false, "verify_hostname": false, "cert": "",直接运行起来~/trojan-1.15]# ./trojan -c config.json Welcome to trojan 1.15.1 [2022-04-02 11:38:01] [WARN] trojan service (client) started at 127.0.0.1:1080而后配置一个privoxyyum install privoxy -y添加配置文件listen-address 127.0.0.1:1081 toggle 0 show-on-task-bar 0 activity-animation 0 forward-socks5 / 127.0.0.1:1080 . hide-console并启动systemctl start privoxy.serviceexport http_proxy=http://localhost:1081/ export https_proxy=http://localhost:1081/打开一下谷歌# curl -o /dev/null -s -w "%{http_code}" www.google.com && echo 200返回追踪下日志# ./trojan -c config.json Welcome to trojan 1.15.1 [2022-04-02 11:38:01] [WARN] trojan service (client) started at 127.0.0.1:1080 [2022-04-02 11:39:21] [INFO] 127.0.0.1:42136 requested connection to www.google.com:80 [2022-04-02 11:39:22] [INFO] 127.0.0.1:42136 disconnected, 14790 bytes received, 78 bytes sent, lasted for 1 seconds [2022-04-02 11:39:37] [INFO] 127.0.0.1:42302 requested connection to www.google.com:80 [2022-04-02 11:39:57] [ERROR] 127.0.0.1:42302 cannot resolve remote server hostname de1-1.nigirocloud.com: Host not found (authoritative) [2022-04-02 11:39:57] [INFO] 127.0.0.1:42302 disconnected, 0 bytes received, 78 bytes sent, lasted for 20 seconds [2022-04-02 11:40:54] [INFO] 127.0.0.1:43156 requested connection to www.google.com:80 [2022-04-02 11:41:04] [ERROR] 127.0.0.1:43156 cannot resolve remote server hostname de1-1.nigirocloud.com: Host not found (authoritative) [2022-04-02 11:41:04] [INFO] 127.0.0.1:43156 disconnected, 0 bytes received, 78 bytes sent, lasted for 10 seconds [2022-04-02 11:41:14] [INFO] 127.0.0.1:43380 requested connection to www.google.com:80 [2022-04-02 11:41:15] [INFO] 127.0.0.1:43380 disconnected, 14783 bytes received, 78 bytes sent, lasted for 1 seconds [2022-04-02 11:41:32] [INFO] 127.0.0.1:43596 requested connection to www.google.com:80 [2022-04-02 11:41:33] [INFO] 127.0.0.1:43596 disconnected, 14806 bytes received, 78 bytes sent, lasted for 1 seconds [2022-04-02 11:41:35] [INFO] 127.0.0.1:43626 requested connection to www.google.com:80 [2022-04-02 11:41:41] [INFO] 127.0.0.1:43626 disconnected, 14805 bytes received, 78 bytes sent, lasted for 6 seconds [2022-04-02 11:41:44] [INFO] 127.0.0.1:43734 requested connection to www.google.com:80 [2022-04-02 11:41:45] [INFO] 127.0.0.1:43734 disconnected, 14823 bytes received, 78 bytes sent, lasted for 1 seconds [2022-04-02 11:41:51] [INFO] 127.0.0.1:43830 requested connection to www.google.com:80 [2022-04-02 11:41:52] [INFO] 127.0.0.1:43830 disconnected, 14759 bytes received, 78 bytes sent, lasted for 1 seconds现在就可以发起http的请求
2022年04月02日
1,087 阅读
0 评论
0 点赞
2022-03-15
linuxea:openssl和openssh[CVE-2021-3711]修复
修复了 SM2 解密缓冲区溢出。[CVE-2021-3711])Changes between 1.1.1k and 1.1.1l [24 Aug 2021] Fixed an SM2 Decryption Buffer Overflow. In order to decrypt SM2 encrypted data an application is expected to call the API function EVP_PKEY_decrypt(). Typically an application will call this function twice. The first time, on entry, the "out" parameter can be NULL and, on exit, the "outlen" parameter is populated with the buffer size required to hold the decrypted plaintext. The application can then allocate a sufficiently sized buffer and call EVP_PKEY_decrypt() again, but this time passing a non-NULL value for the "out" parameter. A bug in the implementation of the SM2 decryption code means that the calculation of the buffer size required to hold the plaintext returned by the first call to EVP_PKEY_decrypt() can be smaller than the actual size required by the second call. This can lead to a buffer overflow when EVP_PKEY_decrypt() is called by the application a second time with a buffer that is too small. A malicious attacker who is able present SM2 content for decryption to an application could cause attacker chosen data to overflow the buffer by up to a maximum of 62 bytes altering the contents of other data held after the buffer, possibly changing application behaviour or causing the application to crash. The location of the buffer is application dependent but is typically heap allocated. ([CVE-2021-3711]) Matt Caswell1.1.1m 避免两次加载动态引擎。Changes between 1.1.1l and 1.1.1m [xx XXX xxxx] Avoid loading of a dynamic engine twice. Bernd Edlinger Prioritise DANE TLSA issuer certs over peer certs Viktor Dukhovni Fixed random API for MacOS prior to 10.12 These MacOS versions don't support the CommonCrypto APIs Lenny Primakopenssl小版本,比如修复什么小bug,单并不影响稳定性是按照字母顺序进行排版本比如: 1.1.1l到1.1.1m,我门可以查看他的历史版本,最新的版本已经升级到3.0.1依赖包,也可以用做离线使用yum install -y gcc gcc-c++ autoconf automake zlib zlib-devel pcre-devel pam-devel openssl openssl-devel openssl-libs lrzszhttps://www.openssl.org/source/snapshot/opensslrpmrpm包下载: https://github.com/philyuchkoff/openssl-RPM-Builder/releasesrpm -e --justdb --nodeps openssl-libs rpm -e --justdb --nodeps openssl-1:1.0.2k rpm -ivvh openssl-1.1.1m-1.el7.x86_64.rpm --nodeps openssl version推荐编译安装openssl-1.1.1lhttps://www.openssl.org/source/openssl-1.1.1l.tar.gz https://www.openssl.org/source/snapshot/openssl-1.1.1-stable-SNAP-20220120.tar.gz mv /usr/bin/openssl{,.bak} mv /usr/include/openssl{,.bak} cd /usr/local/openssl-1.1.1m/ ./config shared && make && make installopenssl-1.1.1mhttps://www.openssl.org/source/openssl-1.1.1m.tar.gzwget --no-check-certificate https://www.openssl.org/source/openssl-1.1.1m.tar.gz tar xf openssl-1.1.1m.tar.gz -C /usr/local/ mv /usr/bin/openssl{,.bak} mv /usr/include/openssl{,.bak} cd /usr/local/openssl-1.1.1m ./config shared && make && make install链接ll /usr/local/bin/openssl ll -d /usr/local/include/openssl/ ln -s /usr/local/bin/openssl /usr/bin/openssl ln -s /usr/local/include/openssl/ /usr/include/openssl ll /usr/bin/openssl ll -d /usr/include/openssl echo "/usr/local/lib64" >> /etc/ld.so.conf /sbin/ldconfig openssl version openssl version -aopenssh安装依赖包yum install -y gcc gcc-c++ autoconf automake zlib zlib-devel pcre-devel pam-devel openssl openssl-devel openssl-libs配置必要的编译选项mv /etc/ssh{,.bak} mkdir /usr/local/openssh curl -Lk https://openbsd.hk/pub/OpenBSD/OpenSSH/portable/openssh-8.7p1.tar.gz |tar xz -C ./ cd openssh-8.7p1/ ./configure --prefix=/usr/local/openssh \ --sysconfdir=/etc/ssh \ --with-openssl-includes=/usr/local/include \ --with-ssl-dir=/usr/local/lib64 \ --with-zlib \ --with-md5-passwords \ --with-pam && \ make && \ make install简单的配置下sshdecho "UseDNS no" >> /etc/ssh/sshd_config echo "Port 6789" >> /etc/ssh/sshd_config echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config echo 'PubkeyAuthentication yes' >> /etc/ssh/sshd_config echo 'PasswordAuthentication yes' >> /etc/ssh/sshd_config mv /usr/sbin/sshd{,.bak} mv /usr/bin/ssh{,.bak} mv /usr/bin/ssh-keygen{,.bak} ln -s /usr/local/openssh/bin/ssh /usr/bin/ssh ln -s /usr/local/openssh/bin/ssh-keygen /usr/bin/ssh-keygen ln -s /usr/local/openssh/sbin/sshd /usr/sbin/sshd ssh -V配置开机启动systemctl disable sshd --now mv /usr/lib/systemd/system/sshd.service{,.bak} systemctl daemon-reload \cp -a contrib/redhat/sshd.init /etc/init.d/sshd \cp -a contrib/redhat/sshd.pam /etc/pam.d/sshd.pam chkconfig --add sshd systemctl enable sshd --now systemctl start sshd ssh -V
2022年03月15日
921 阅读
0 评论
1 点赞
2022-02-23
linuxea:docker-compose vsftpd 3.0.3快速配置
VSFTPD 代表“非常安全的 FTP 守护程序”,是一个 GPL 许可的 UNIX 系统 FTP 服务器。它是根据 GNU 通用公共许可证获得许可的。它支持 IPv6 和 SSL。vsftpd 支持显式(自 2.0.0 起)和隐式(自 2.1.0 起)FTPS。vsftpd 是 Ubuntu、CentOS、Fedora、NimbleX、Slackware 和 RHEL Linux 发行版中的默认 FTP 服务器。它安全且速度极快。它是稳定的。VSFTPD 是一个成熟且值得信赖的解决方案,它通过 PAM(可插入身份验证模块)支持虚拟用户。虚拟用户是在 /etc/passwd 和 /etc/shadow 文件中不作为系统上的真实登录存在的用户登录。因此,虚拟用户可以比真实用户更安全,因为被入侵的帐户只能使用 FTP 服务器,但不能登录系统使用其他服务,例如 SSH 或 SMTP。2011 年 7 月,发现可从主站点下载的 VSFTPD 版本 2.3.4 已被入侵。登录受感染的 vsftpd-2.3.4 服务器的用户可能会发出“:)”笑脸作为用户名,并在端口 6200 上获得命令 shell。这不是 VSFTPD 中的安全漏洞问题,而是有人上传了包含后门的不同版本的 VSFTPD。从那时起,该网站被移至 Google App Engine。特征尽管出于速度和安全性的目的很小,但使用 vsftpd 可以实现许多更复杂的 FTP 设置!vsftpd 可以处理:虚拟 IP 配置虚拟用户独立或 inetd 操作强大的每用户可配置性带宽限制每源 IP 可配置性每源 IP 限制docker我们使用的是 markhobson/vsftpd:3.0.3的docker镜像这个 Docker 容器实现了一个 vsftpd 服务器,具有以下特性:Centos 8 基础镜像。vsftpd 3.0虚拟用户被动模式记录到文件或 STDOUT。支持的环境变量如下:环境变量此图像使用环境变量来允许在运行时配置一些参数:变量名:FTP_USER默认值:管理员接受的值:任何字符串。避免使用空格和特殊字符。说明:默认 FTP 帐户的用户名。如果在运行时没有通过FTP_USER环境变量指定admin,默认会使用。变量名:FTP_PASS默认值:随机字符串。接受的值:任何字符串。说明:如果不通过 指定默认FTP账号的密码,FTP_PASS会自动生成一个16个字符的随机字符串。你可以通过容器日志获取该值。变量名:PASV_ADDRESS默认值:Docker 主机 IP / 主机名。接受的值:任何 IPv4 地址或主机名(请参阅 PASV_ADDRESS_RESOLVE)。说明:如果你不指定要在被动模式下使用的 IP 地址,则将使用 Docker 主机的路由 IP 地址。请记住,这可能是本地地址。变量名:PASV_ADDR_RESOLVE默认值:否接受的值:<NO|YES>说明:如果你想在 PASV_ADDRESS 选项中使用主机名(而不是 IP 地址),请设置为 YES。变量名:PASV_ENABLE默认值:是接受的值:<NO|YES>说明:如果要禁止 PASV 方法获取数据连接,请设置为 NO。变量名:PASV_MIN_PORT默认值:21100接受的值:任何有效的端口号。说明:这将用作被动模式端口范围的下限。请记住使用docker -p参数发布你的端口。变量名:PASV_MAX_PORT默认值:21110接受的值:任何有效的端口号。说明:这将用作被动模式端口范围的上限。启动具有大量已发布端口的容器将需要更长的时间。变量名:XFERLOG_STD_FORMAT默认值:否接受的值:<NO|YES>说明:如果你希望传输日志文件以标准 xferlog 格式写入,请设置为 YES。变量名:LOG_STDOUT默认值:空字符串。接受的值:任何要启用的字符串、空字符串或未定义为禁用。说明:通过STDOUT输出vsftpd日志,以便通过容器日志访问。变量名:FILE_OPEN_MODE默认值:0666接受的值:文件系统权限。描述:创建上传文件的权限。Umasks 应用在这个值之上。如果你希望上传的文件可执行,你可能希望更改为 0777。变量名:LOCAL_UMASK默认值:077接受的值:文件系统权限。说明:为本地用户设置的用于文件创建的 umask 的值。笔记!如果要指定八进制值,请记住“0”前缀,否则该值将被视为以 10 为底的整数!变量名:REVERSE_LOOKUP_ENABLE默认值:是接受的值:<NO|YES>说明:如果你想避免名称服务器不响应反向查找的性能问题,请设置为 NO。变量名:PASV_PROMISCUOUS默认值:否接受的值:<NO|YES>说明:如果要禁用 PASV 安全检查以确保数据连接来自与控制连接相同的 IP 地址,请设置为 YES。仅当你知道自己在做什么时才启用!唯一合法的用途是某种形式的安全隧道方案,或者可能是为了促进 FXP 支持。变量名:PORT_PROMISCUOUS默认值:否接受的值:<NO|YES>说明:如果要禁用 PORT 安全检查以确保传出数据连接只能连接到客户端,请设置为 YES。仅当你知道自己在做什么时才启用!对此的合法用途是促进 FXP 支持。变量名:SSL_ENABLE默认值:否接受值:YES 或 NO。说明:如果要启用 SSL 加密,请设置为 YES - 制作 FTPS 服务器。变量名:TLS_CERT默认值:cert.pem接受的值:任何字符串表示文件名的扩展名说明:应位于/etc/vsftpd/cert/容器中的证书文件名。变量名:TLS_KEY默认值:key.pem接受的值:任何字符串表示文件名的扩展名描述:应该位于/etc/vsftpd/cert/容器中的密钥文件名。暴露的端口和卷该图像暴露了端口20和21. 此外,导出三个卷:/home/vsftpd,包含用户主目录,/var/log/vsftpd,用于存储日志和/etc/vsftpd/cert,为容器提供 SSL 证书。在主机和容器 ( /home/vsftpd) 之间共享主目录时,所有者用户 ID 和组 ID 应分别为 14 和 50。这对应于容器上的 ftp 用户和 ftp 组,但可能与主机上的其他内容匹配。docker-compose ftpversion: '2.4' services: rabbitmq: image: markhobson/vsftpd:3.0.3 container_name: vsftpd restart: always hostname: "vsftp" network_mode: "host" environment: - FTP_USER=marksugar - FTP_PASS=linuxea - PASV_ADDRESS=IPADRESS #- PASV_ADDR_RESOLVE=YES - PASV_MIN_PORT=21100 - PASV_MAX_PORT=21110 - FASV_MAX_PER_IP=20000 - FASV_MAX_CLIENTS=200000 #- FILE_OPEN_MODE=0666 #- LOCAL_UMASK=077 #- REVERSE_LOOKUP_ENABLE=NO volumes: - /data/vsftp:/home/vsftpd mem_limit: 2048m而后runing起来docker-compose -f vsftpd.yaml up -dftp客户端工具对于客户端工具可以考虑sftp和FileZilla,更推荐FileZilla我们需要注意下字符集传输,一般默认即可,特殊情况需要修改字符集的情况,特别是中文的时候filezillasftp断点续传
2022年02月23日
1,211 阅读
0 评论
0 点赞
2022-02-21
linuxea:局域网ntp和chronyd时间同步的简单配置
在某些环境下,我们需要ntp服务器,同时我们可能还需要配置chronyd来同步我们的节点时间,而在k8s的环境中,服务器的时间是需要同步的,并且在一些警报中是会检测,为了解决这个问题,在一些局域网内没有互联网的情况下,就需要手动配置ntp通过yum install 方式来安装ntp服务,而后我们配置一个server 192.168.5.26 iburstprefer:优先使用该时间服务器burst:当一个运程NTP服务器可用时,向它发送一系列的并发包进行检测。iburst:当一个运程NTP服务器不可用时,向它发送一系列的并发包进行检测。“iburst” 选项作用是如果在一个标准的轮询间隔内没有应答,客户端会发送一定数量的包(八个包而不是通常的一个)给 NTP 服务器。如果在短时间内呼叫 NTP 服务器几次,没有出现可辨识的应答,那么本地时间将不会变化通常情况,大多数只是在没有公网环境的情况下配置一个内网的,小局域网内的一个环境使用/etc/ntp.confdriftfile /var/lib/ntp/ntp.drift statistics loopstats peerstats clockstats filegen loopstats file loopstats type day enable filegen peerstats file peerstats type day enable filegen clockstats file clockstats type day enable server ntp1.aliyun.com prefer server 192.168.5.26 iburst server ntp.aliyun.com prefer server 2.centos.pool.ntp.org iburst server 3.centos.pool.ntp.org iburst #server ntp.ubuntu.com server 127.127.1.0 fudge 127.127.1.0 stratum 5 restrict -4 default kod notrap nomodify nopeer noquery restrict -6 default kod notrap nomodify nopeer noquery restrict 17.168.0.0 mask 255.255.255.0 nomodify restrict 127.0.0.1 restrict ::1 #https://www.jianshu.com/p/e5e486c8e365而后开启即可systemctl start ntpd systemctl enable ntpdchronydChrony是一个开源的自由软件,如果在chrony配置文件中指定了ntp服务器的地址,那么chrony就是一台客户端,会去同步ntp服务器的时间,如果在chrony配置了允许某些客户端来向自己同步时间,则chrony也充当了一台服务器,所以,安装了chrony即可充当客户端也可以充当服务端。Chrony有两个核心组件,分别是:chronyd:是守护进程,主要用于调整内核中运行的系统时间和时间服务器同步。它确定计算机增减时间的比率,并对此进行调整补偿。chronyc:提供一个用户界面,用于监控性能并进行多样化的配置。它可以在chronyd实例控制的计算机上工作,也可以在一台不同的远程计算机上工作。ntpd同步时间某些时候需要长时间来同步时间,在Centos7中的chrony也实现时间同步hrony兼容ntpd监听在udp123端口上,另外还监听在udp的323端口上。我们通过yum install -y chrony进行安装通常k8s在时间同步上是使用的是chronyd来判断的,NTP synchronized,如下~ # timedatectl Local time: 五 2021-10-29 15:05:00 CST Universal time: 五 2021-10-29 07:05:00 UTC RTC time: 五 2021-10-29 07:05:09 Time zone: Asia/Shanghai (CST, +0800) NTP enabled: yes NTP synchronized: no RTC in local TZ: no DST active: n/a我们停掉ntpd systemctl stop ntpd cp /etc/chrony.conf{,.bak} systemctl stop ntpd配置一个基于阿里云ntp.aliyun.com的chrony的地址,我们假设上面的ntp就是chrond要使用的服务器,如下cp /etc/chrony.conf{,.bak} cat > /etc/chrony.conf << EOF server 192.168.5.26 server ntp1.aliyun.com server ntp2.aliyun.com driftfile /var/lib/chrony/drift makestep 1.0 3 rtcsync logdir /var/log/chrony EOF systemctl enable --now chronyd systemctl restart chronyd chronyc activity chronyc sources firewall-cmd --add-service=ntp --permanent firewall-cmd --reload而后配置开机启动,兵重启systemctl enable --now chronyd systemctl restart chronyd chronyc activity chronyc sources firewall-cmd --add-service=ntp --permanent firewall-cmd --reload查看她的状态[root@linuxea.com ~]# chronyc activity 200 OK 1 sources online 0 sources offline 0 sources doing burst (return to online) 0 sources doing burst (return to offline) 0 sources with unknown address [root@linuxea.com ~]# chronyc sources 210 Number of sources = 1 MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^? 17.168.0.165 3 6 3 12 -4527us[-4527us] +/- 51ms[root@linuxea.com ~]# chronyc sources -v 210 Number of sources = 1 .-- Source mode '^' = server, '=' = peer, '#' = local clock. / .- Source state '*' = current synced, '+' = combined , '-' = not combined, | / '?' = unreachable, 'x' = time may be in error, '~' = time too variable. || .- xxxx [ yyyy ] +/- zzzz || Reachability register (octal) -. | xxxx = adjusted offset, || Log2(Polling interval) --. | | yyyy = measured offset, || \ | | zzzz = estimated error. || | | \ MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^* 17.168.0.165 3 6 7 14 -5642ns[ -33.3s] +/- 62ms[root@linuxea.com ~]# chronyc tracking Reference ID : 11A800A5 (17.168.0.165) Stratum : 4 Ref time (UTC) : Fri Oct 29 07:09:14 2021 System time : 0.000000000 seconds slow of NTP time Last offset : -33.251636505 seconds RMS offset : 33.251636505 seconds Frequency : 10.242 ppm slow Residual freq : -0.000 ppm Skew : 63.129 ppm Root delay : 0.048810445 seconds Root dispersion : 0.042059928 seconds Update interval : 0.0 seconds Leap status : Normal最后我们在观察,这里的NTP synchronized: 已经是yes`状态[root@linuxea.com ~]# timedatectl Local time: 五 2021-10-29 15:10:56 CST Universal time: 五 2021-10-29 07:10:56 UTC RTC time: 五 2021-10-29 07:10:32 Time zone: Asia/Shanghai (CST, +0800) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: n/a参考Chrony-替换你的NTP服务
2022年02月21日
1,331 阅读
0 评论
0 点赞
2020-11-25
linuxea:firewall简单使用笔记
FirewallD使用服务和区域的概念,而不是iptables规则和链。使用它,您可以配置应该允许或禁止与系统之间的通信。FirewallD使用firewall-cmd实用程序来管理防火墙配置。LinuxEA # firewall-cmd --list-all FirewallD is not running启动并启用LinuxEA # systemctl start firewalld LinuxEA # systemctl enable firewalld Created symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service → /usr/lib/systemd/system/firewalld.service. Created symlink /etc/systemd/system/multi-user.target.wants/firewalld.service → /usr/lib/systemd/system/firewalld.service.状态已经运行LinuxEA # firewall-cmd --state running以下是FirewallD中包含的预定义区域:这些可以使用firewall-cmd --get-zones来获取drop –丢弃所有传入连接,不作任何答复,只允许传出连接。block –与区域删除相同,但所有传入连接均使用icmp-host- prohibited或icmp6-adm-prohibited消息阻止。public -它代表不可靠的公共区域。external -防火墙用作网关的外部网络。因为它是为NAT伪装而配置的,所以内部网络将保持私有但可访问。internal –仅接受选定的传入连接,用于内部网络。dmz –非军事区,内部网络可公开访问,访问受限,并且仅接受选定的传入连接。work –用于工作机。home -使用的家用机。trusted -接受所有网络连接。使用FirewallD配置防火墙默认情况下,public域是启用防火墙服务后的默认区域。LinuxEA # firewall-cmd --get-default-zone public使用--get-zones可以看到所有区域LinuxEA # firewall-cmd --get-zones block dmz drop external home internal public trusted work--get-active-zones 查看网络接口使用了哪些区域LinuxEA # firewall-cmd --get-active-zones public interfaces: eth0可以使用--set-default-zone=""和--get-default-zone来设置和查看# firewall-cmd --set-default-zone=drop 比如更改为home域或者drop域 # firewall-cmd --get-default-zone对外开放服务打开http和https临时打开对外开放http和httpsLinuxEA # firewall-cmd --zone=drop --add-service=http success LinuxEA # firewall-cmd --zone=drop --add-service=https success永久写入: --permanentLinuxEA # firewall-cmd --zone=drop --permanent --add-service=http success LinuxEA # firewall-cmd --zone=drop --permanent --add-service=https success或者这样LinuxEA # firewall-cmd --zone=drop --permanent --add-port 80/tcp success LinuxEA # firewall-cmd --zone=drop --permanent --add-port 443/tcp success如果有多个端口,比如开启:80到100端口LinuxEA # firewall-cmd --zone=drop --permanent --add-port 80-100/tcpORLinuxEA # firewall-cmd --zone=drop --permanent --add-port={80/tcp,443/tcp,8080/tcp,9000-9086/tcp} success如果有多个服务LinuxEA # firewall-cmd --zone=drop --permanent --add-service={http,https,dns,jenkins} success如果要查看这些端口,则可以使用--info-service=NAME,这些信息预置在/usr/lib/firewalld/services目录下。如下:LinuxEA # firewall-cmd --info-service=jenkins jenkins ports: 8080/tcp protocols: source-ports: modules: destination: includes: helpers: 而后重新加载LinuxEA # firewall-cmd --reload success使用--list-all查看LinuxEA # firewall-cmd --list-all drop (active) target: DROP icmp-block-inversion: no interfaces: ens33 sources: services: dns http https jenkins ports: 80/tcp 443/tcp 8080/tcp 9000-9086/tcp protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules: 删除规则LinuxEA # firewall-cmd --zone=drop --permanent --remove-service=http success LinuxEA # firewall-cmd --zone=drop --permanent --remove-service=https success或者LinuxEA # firewall-cmd --zone=drop --permanent --remove-port 80/tcp success LinuxEA # firewall-cmd --zone=drop --permanent --remove-port 443/tcp successLinuxEA # firewall-cmd --reload successLinuxEA # firewall-cmd --list-all drop (active) target: DROP icmp-block-inversion: no interfaces: ens33 sources: services: dns jenkins ports: 8080/tcp 9000-9086/tcp protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules: 源ip地址管理可以将区域绑定到网络接口和地址: 对于drop区域,放行172.16.100.0/24网段LinuxEA # firewall-cmd --permanent --zone=drop --add-source=172.16.100.0/24 success LinuxEA # firewall-cmd --reload success移除--remove-sourceLinuxEA # firewall-cmd --permanent --zone=drop --remove-source=172.16.100.0/24 success LinuxEA # firewall-cmd --reload success LinuxEA # firewall-cmd --list-all drop (active) target: DROP icmp-block-inversion: no interfaces: ens33 sources: services: ports: protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules:还有修改-change-source可以对Mac地址进行管理 firewall-cmd --permanent --zone=drop --add-source=80-FA-5B-25-3B-1A丰富的Rich Rules由于rich规则所使用的语法很难记住,因此请记住man firewalld.richlanguage命令和最后的“示例”部分。格式如下:firewall-cmd --add-rich-rule 'rule ...'允许172.16.100.107所有的连接请求。--add-rich-rulefirewall-cmd --permanent --zone=drop --add-rich-rule="rule family="ipv4" source address="172.16.100.107" accept" log 可以使用log选项记录日志到 /var/log/messagesfirewall-cmd --permanent --zone=drop --add-rich-rule="rule family="ipv4" source address="172.16.100.107" log accept" 使用--list-allLinuxEA # firewall-cmd --list-all drop (active) target: DROP icmp-block-inversion: no interfaces: ens33 sources: services: dns jenkins ports: 8080/tcp 9000-9086/tcp protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules: rule family="ipv4" source address="172.16.100.107" accept rule family="ipv4" source address="172.16.100.107" log accept或者这样添加ip段 172.16.100.0/24LinuxEA # firewall-cmd --permanent --zone=drop --add-rich-rule='rule family="ipv4" source address="172.16.100.0/24" port port="22-23" protocol="tcp" accept' success LinuxEA # firewall-cmd --reload success删除允许172.16.100.107所有的连接请求。 --remove-rich-rulefirewall-cmd --permanent --zone=drop --remove-rich-rule="rule family="ipv4" source address="172.16.100.107" accept" 允许ip和拒绝ip# 根据ip接受所有端口 firewall-cmd --permanent --zone=drop --add-rich-rule="rule family="ipv4" source address="172.16.100.107" accept" # 根据ip拒绝所有端口 firewall-cmd --permanent --zone=drop --add-rich-rule="rule family="ipv4" source address="172.16.100.107" drop" 禁用pingfirewall-cmd --permanent --zone=drop --add-rich-rule='rule protocol value=icmp drop'删除zone删除/etc/firewalld/zones下的zone命名的xml文件而后重新加载即可Direct rulesfirewall-cmd工具中的--direct选项可以在运行时添加和删除链。直接接口模式可以让服务或者程序在运行时候添加特定的防火墙。作用于文件 /etc/firewalld/direct.xml将规则添加到INPUT链,放行8090端口LinuxEA # firewall-cmd --direct --permanent --zone=drop --add-rule ipv4 filter INPUT 0 -p tcp --dport 8090 -j ACCEPT success查看iptablesLinuxEA # iptables -L -n Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:53 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:8090用firewall查看LinuxEA # firewall-cmd --direct --get-all-rules ipv4 filter INPUT 0 -p tcp --dport 8090 -j ACCEPT请注意,此命令(该--get-rules选项)仅列出以前使用该--add-rule选项添加的规则。它没有列出通过其他方式添加的现有iptables规则。删除LinuxEA # firewall-cmd --direct --permanent --zone=drop --remove-rule ipv4 filter INPUT 0 -p tcp --dport 8090 -j ACCEPT如果你在初始化系统这条命令可以放行sshfirewall-offline-cmd --direct --add-rule ipv4 filter INPUT 0 -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPTip set管理firewall有ipset的功能。 ipset是一组IP地址或网络。不同的区域类别,属于hash:ip或hash:net。配置黑名单ip创建ip组:blacklist1LinuxEA # firewall-cmd --permanent --zone=drop --new-ipset=blacklist1 --type=hash:ip success LinuxEA # firewall-cmd --reload success添加ip成员注意:添加--option=family=inet6以创建IPv6 ipset。LinuxEA # firewall-cmd --permanent --ipset=blacklist1 --add-entry=172.16.100.101 success LinuxEA # firewall-cmd --permanent --ipset=blacklist1 --add-entry=172.16.100.3 success添加拒绝规则LinuxEA # firewall-cmd --permanent --add-rich-rule='rule source ipset=blacklist1 drop' success获取blacklist1成员LinuxEA # firewall-cmd --info-ipset=blacklist1 blacklist1 type: hash:ip options: entries: 172.16.100.101 172.16.100.3删除组内ip成员LinuxEA # firewall-cmd --ipset=blacklist1 --remove-entry=172.16.100.101 success LinuxEA # firewall-cmd --ipset=blacklist1 --get-entries 172.16.100.3配置黑名单ip段创建新的黑名单netblacklist,类型hash:netLinuxEA # firewall-cmd --permanent --new-ipset=netblacklist --type=hash:net --option=family=inet --option=hashsize=4096 --option=maxelem=200000 successLinuxEA # firewall-cmd --reload successLinuxEA # firewall-cmd --info-ipset=netblacklist netblacklist type: hash:net options: family=inet hashsize=4096 maxelem=200000 entries: 添加两个网段LinuxEA # firewall-cmd --permanent --ipset=netblacklist --add-entry=172.16.100.0/24 successLinuxEA # firewall-cmd --permanent --ipset=netblacklist --add-entry=192.168.2.0/24 successLinuxEA # firewall-cmd --info-ipset=netblacklist netblacklist type: hash:net options: family=inet hashsize=4096 maxelem=200000 entries: 172.16.100.0/24 192.168.2.0/24或者添加一个ip文件列表LinuxEA # cat > iplist.txt <<EOL > 10.10.1.0/23 > 192.168.0.3 > 172.16.100.0/24 > 172.16.90.0/24 > EOL--add-entries-from-file添加,改成--remove-entries-from-file就删除LinuxEA # firewall-cmd --permanent --ipset=netblacklist --add-entries-from-file=iplist.txt successfirewall-cmd --permanent --ipset=netblacklist --remove-entries-from-file=iplist.txt单个添加和单个删除LinuxEA # firewall-cmd --permanent --ipset=netblacklist --add-entry=172.16.100.118 successfirewall-cmd --permanent --ipset=netblacklist --remove-entry=172.16.100.118LinuxEA # firewall-cmd --reload successLinuxEA # firewall-cmd --info-ipset=netblacklist netblacklist type: hash:net options: family=inet hashsize=4096 maxelem=200000 entries: 172.16.100.0/24 192.168.2.0/24 10.10.1.0/23 192.168.0.3 172.16.90.0/24没有丢弃参数,没有iptables命令,也没有与IP数据包相关的内容。这是因为使用的是firewalld的源功能,当一个IP地址与源(源接口,源IP甚至源MAC地址)匹配时,上述规则会将IP地址重定向到特定区域,在这种情况下为“阻止”。作用到某个区域firewall-cmd --permanent --zone=drop --add-source=ipset:netblacklist从区域内删除firewall-cmd --permanent --zone=drop --remove-source=ipset:netblacklist管理命令查看ipsetLinuxEA # firewall-cmd --permanent --get-ipsets blacklist1 netblacklist查看ipset表LinuxEA # firewall-cmd --permanent --info-ipset=netblacklist netblacklist type: hash:net options: family=inet hashsize=4096 maxelem=200000 entries: 172.16.100.0/24 192.168.2.0/24 10.10.1.0/23 192.168.0.3 172.16.90.0/24LinuxEA # firewall-cmd --permanent --info-ipset=blacklist1 blacklist1 type: hash:ip options: entries: 端口转发sysctl -w net.ipv4.ip_forward=1如果防火墙是您的网络网关,并且不希望所有人都知道您的内部地址,则可以设置两个区域,一个称为内部区域,另一个称为外部区域,并在外部区域上配置伪装。 这样,所有数据包都将获取您的防火墙IP地址作为源地址。端口转发是一种将特定端口的入站网络流量转发到另一个内部地址或备用端口的方法端口转发需要masquerading ,因此创建LinuxEA # firewall-cmd --zone=external --add-masquerade success如果希望暂时将所有要发送给端口22的数据包转发到端口tcp 3753LinuxEA # firewall-cmd --zone=external --add-forward-port=port=22:proto=tcp:toport=3753 success把80端口转发到后端的172.25.100.2 8080firewall-cmd --permanent --add-forward port=80:proto=tcp:toaddr=172.25.100.2:toport=8080要删除端口转发,使用-remove-forward-port选项firewall-cmd --zone=external --remove-forward-port=port=22:proto=tcp:toport=3753如果要定义目标IP地址:LinuxEA # firewall-cmd --permanent --zone=external --add-forward-port=port=22:proto=tcp:toport=3753:toaddr=172.16.100.101 success LinuxEA # firewall-cmd --reload success--permanent永久生效示例:假如现在希望通过SSH从public (10.10.1.0/24)访问dmz网络(10.8.8.0/24)上的服务器。为此,我们需要放置一些端口转发规则。以下规则配置端口转发,以便将与10.10.1.79:2271的连接转发到10.8.8.71:22,并进行SSH日志记录# firewall-cmd --permanent --zone=public --add-forward-port='port=2271:proto=tcp:toport=22:toaddr=10.8.8.71' # firewall-cmd --permanent --zone=public --add-rich-rule='rule service name=ssh log prefix="SSH_" level="debug" limit value=1/m reject' # firewall-cmd --reload普通配置示例# 创建linuxea区域 firewall-cmd --permanent --new-zone=linuxea firewall-cmd --reload删除zone只需要删除/etc/firewalld/zones下的zone命名的xml文件而后重新加载即可# 修改默认域为linuxea firewall-cmd --set-default-zone=linuxea # 放行https,http firewall-cmd --permanent --zone=linuxea --add-service={http,https} # 运行172.16.100.101登录ssh firewall-cmd --permanent --zone=linuxea --add-rich-rule='rule family="ipv4" source address="172.16.100.101" port port="22" protocol="tcp" accept' # 允许10.100.10.0/24网段访问8080端口 firewall-cmd --permanent --zone=linuxea --add-rich-rule='rule family="ipv4" source address="10.100.10.0/24" port port="8080" protocol="tcp" accept' # 拒绝10.100.100.4访问80端口 firewall-cmd --permanent --zone=linuxea --add-rich-rule='rule family="ipv4" source address="10.100.100.4" port port="80" protocol="tcp" drop'# 重载 LinuxEA # firewall-cmd --reload success # 查看规则 LinuxEA # firewall-cmd --list-all linuxea (active) target: default icmp-block-inversion: no interfaces: ens33 sources: services: http https ports: protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules: rule family="ipv4" source address="172.16.100.101" port port="22" protocol="tcp" accept rule family="ipv4" source address="10.100.100.4" port port="80" protocol="tcp" drop rule family="ipv4" source address="10.100.10.0/24" port port="8080" protocol="tcp" accept紧急模式firewall-cmd --panic-on 执行端口所有连接 firewall-cmd --panic-off 关闭 firewall-cmd --query-panic 查询
2020年11月25日
2,224 阅读
0 评论
0 点赞
2020-03-21
linuxea: lsyncd快速配置安装
Lsyncd-实时同步相比较之前的rsync同步的方式,他可以通过ssh的方式进行同步,这也是为什么要写这篇笔记的原因。通常而言,越简单越高效的东西都有必要和价值来进行分享。rsync+ssh配置起来更加复杂,ssh操作文件和目录。通过配置文件来做自定义配置,使用shell脚本和lua语言编写。配置简单,灵活,详细查看官网手册:https://axkibe.github.io/lsyncd/lsyncd2.2.1需要在源节点和目标节点安装rsync>=3.1。这个需求通常来讲系统自带的就足够了。因此,我们要安装的依赖包就包括lua,liblua,以及cmake:yum install lua lua-devel cmake -y克隆代码[root@linuxea_node ~]# git clone https://github.com/axkibe/lsyncd.git /usr/local/lsyncd Cloning into '/usr/local/lsyncd'... remote: Enumerating objects: 4333, done. remote: Total 4333 (delta 0), reused 0 (delta 0), pack-reused 4333 Receiving objects: 100% (4333/4333), 1.76 MiB | 780.00 KiB/s, done. Resolving deltas: 100% (2577/2577), done.安装依赖包安装几个依赖包[root@linuxea_node ~]# cd /usr/local/lsyncd [root@linuxea_node /usr/local/lsyncd]# yum install lua lua-devel cmake -y编译安装安装完成后进行编译即可[root@linuxea_node /usr/local/lsyncd]# cmake . -- The C compiler identification is GNU 4.8.5 -- The CXX compiler identification is GNU 4.8.5 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Found Lua: /usr/lib64/liblua.so;/usr/lib64/libm.so (found version "5.1.4") -- Configuring done -- Generating done -- Build files have been written to: /usr/local/lsyncd[root@linuxea_node /usr/local/lsyncd]# make [ 12%] Generating defaults.out Compiling built-in default configs [ 25%] Generating runner.out Compiling built-in runner [ 37%] Generating runner.c Generating built-in runner linkable [ 50%] Generating defaults.c Generating built-in default configs Scanning dependencies of target lsyncd [ 62%] Building C object CMakeFiles/lsyncd.dir/lsyncd.c.o [ 75%] Building C object CMakeFiles/lsyncd.dir/runner.c.o [ 87%] Building C object CMakeFiles/lsyncd.dir/defaults.c.o [100%] Building C object CMakeFiles/lsyncd.dir/inotify.c.o Linking C executable lsyncd [100%] Built target lsyncd[root@linuxea_node /usr/local/lsyncd]# make install [100%] Built target lsyncd Install the project... -- Install configuration: "" -- Installing: /usr/local/bin/lsyncd -- Installing: /usr/local/man/lsyncd.1ssh互通通常而言,我们需要打通目标节点在目标节点放行源节点的端口,假如是iptables,就如下添加iptables -I INPUT 5 -s 172.25.110.49 -p tcp -m tcp -m state --state NEW -m multiport --dports 22,2222 -m comment --comment "ssh" -j ACCEPT在源节点复制key到目标节点[root@linuxea_node /usr/local/lsyncd]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: SHA256:0vgvn8tziq24dxuhg0yLTsVl3OGQNakxeWJUIUWNJPg root@172_30_2_44.cluster.com The key's randomart image is: +---[RSA 2048]----+ | o=OX= | | ..B*+o. | | o+*o | | . =E | | * S . | | = = . . | | o + + . | | o .o*oo. | | . ooo=X* | +----[SHA256]-----+[root@linuxea_node /usr/local/lsyncd]# ssh-copy-id 172.25.110.50 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub" The authenticity of host '172.25.110.50 (172.25.110.50)' can't be established. ECDSA key fingerprint is SHA256:3BVoJtcE0SnDZN3NA9tRMIoiae7d4vi0FkX6ZltAixE. ECDSA key fingerprint is MD5:e0:75:bd:aa:75:13:c7:e0:d6:2f:21:24:1a:45:42:f1. Are you sure you want to continue connecting (yes/no)? yes /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys root@172.25.110.50's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh '172.25.110.50'" and check to make sure that only the key(s) you wanted were added.配置文件我们将nginx的配置文件实时镜像到172.25.110.50上,配置文件如下[root@DT_Node-172_25_244_4 ~]# cat /usr/local/etc/lsyncd.conf -- this file is sync from cserver settings { logfile ="/var/log/nginx_conf_lsyncd.log", statusFile ="/var/run/nginx_conf_lsyncd.status", inotifyMode = "CloseWrite", maxProcesses = 1, insist = true, } servers = { -- "主机位置" "172.25.110.50", -- server2 } for _, server in ipairs(servers) do sync { default.rsyncssh, source="/usr/local/nginx/conf", host=server, targetdir="/usr/local/nginx/conf", maxDelays=5, delay=0, delete="true", exclude={ ".*", "*.tmp" }, rsync = { binary="/usr/bin/rsync", archive = true, compress = true, verbose = true, rsh = "/usr/bin/ssh -p 22992 -o StrictHostKeyChecking=no" } } end启动[root@linuxea_node /usr/local/nginx]# lsyncd -log Exec /usr/local/etc/lsyncd.conf 03:25:20 Normal: --- Startup, daemonizing ---而后,我们清空日志,手动添加文件测试[root@linuxea_node /usr/local/nginx]# > /var/log/nginx_conf_lsyncd.log [root@linuxea_node /usr/local/nginx]# tail -f /var/log/nginx_conf_lsyncd.logtouch一个text.txtroot@linuxea_node ~]# touch /usr/local/nginx/conf/test.txt日志已经显示同步[root@linuxea_node /usr/local/nginx]# tail -f /var/log/nginx_conf_lsyncd.log Sat Mar 21 03:27:19 2020 Normal: Calling rsync with filter-list of new/modified files/dirs /test.txt / Sat Mar 21 03:27:19 2020 Exec: /usr/bin/rsync [<] [/test.txt /] [-gvzsolptD] [--rsh=/usr/bin/ssh -p 22992 -o StrictHostKeyChecking=no] [-r] [--force] [--from0] [--include-from=-] [--exclude=*] [/usr/local/nginx/conf/] [172.25.110.50:/usr/local/nginx/conf/] Sat Mar 21 03:27:19 2020 Exec: one-sweeped pipe sending incremental file list ./ test.txt sent 106 bytes received 38 bytes 288.00 bytes/sec total size is 0 speedup is 0.00 Sat Mar 21 03:27:19 2020 Normal: Finished (list): 0 可以通过远程查看[root@linuxea_node ~]# ssh 172.25.110.50 ls /usr/local/nginx/conf/te* /usr/local/nginx/conf/test.txt配置文件全局设置logfile 定义日志文件 stausFile 定义状态文件 statusInterval 将lsyncd的状态写入上面的statusFile的间隔,默认10秒 nodaemon=true 表示不启用守护模式,默认 inotifyMode 指定inotify监控的事件,默认是CloseWrite,还可以是Modify或CloseWrite or Modify maxProcesses 同步进程的最大个数。假如同时有20个文件需要同步,而maxProcesses = 8,则最大能看到有8个rysnc进程 maxDelays 累计到多少所监控的事件激活一次同步,即使后面的delay延迟时间还未到定义同步参数,可以继续使用maxDelays来重写settings的全局变量。模式运行default.rsync 本地目录间同步,使用rsync,也可以达到使用ssh形式的远程rsync效果,或daemon方式连接远程rsyncd进程; default.direct 本地目录间同步,使用cp、rm等命令完成差异文件备份; default.rsyncssh 同步到远程主机目录,rsync的ssh模式,需要使用key来认证目录设置source 同步的源目录,使用绝对路径。 target 定义目的地址.对应不同的模式有几种写法: /tmp/dest 本地目录同步,可用于direct和rsync模式 172.25.100.10:/tmp/dest 同步到远程服务器目录,可用于rsync和rsyncssh模式 excludeFrom 排除选项,后面指定排除的列表文件,如excludeFrom = "/etc/lsyncd.exclude",如果是简单的排除,可以使用exclude = LIST。这里的排除规则写法与原生rsync有点不同,更为简单:监控路径里的任何部分匹配到一个文本,都会被排除,例如foo可以匹配/bin/foo/bar 如果规则以斜线/开头,则从头开始要匹配全部 如果规则以/结尾,则要匹配监控路径的末尾 ?匹配单个任何字符,但不包括/ *匹配0或多个字符,但不包括/ **匹配0或多个字符,可以是/delaydelay 累计事件,等待rsync同步延时时间,默认15秒(最大累计到1000个不可合并的事件)。也就是15s内监控目录下发生的改动,会累积到一次rsync同步,避免过于频繁的同步。(可合并的意思是,15s内两次修改了同一文件,最后只同步最新的文件)delete 为了保持target与souce完全同步,Lsyncd默认会delete = true来允许同步删除。它除了false,还有startup、runningtrue Lsyncd将在目标上删除任何不在源中的内容。 在启动时和正常操作中被删除的内容。 false 在lsyncd启动后将在目标上不删除任何不在源中的内容, 在启动时和正常操作中被删除的内容。 startup 启动时将执行一次完全文件同步,保证完全一致;正常运行过程中不会删除target中的文件 running 启动前,增加的会同步,删除的不同步;正常运行过程中会删除target中的文件bwlimit 限速,单位kb/s,与rsync相同 compress 压缩传输默认为true。在带宽与cpu负载之间权衡,本地目录同步可以考虑把它设为false perms 默认保留文件权限。如果你打不开官方例子,配置部分可参考中文文档,或者其他
2020年03月21日
3,161 阅读
0 评论
0 点赞
1
2
...
13