linux脚本中action什么意思
时间: 2023-09-16 11:07:45 浏览: 151
在Linux脚本中,"action"通常指的是脚本中的一个操作或动作。它表示脚本要执行的具体任务或命令。在脚本中,你可以定义多个action,每个action都代表一个特定的任务或命令,比如创建文件、复制文件、运行程序等。通过使用不同的action,你可以按照特定的顺序执行一系列操作,以实现你想要的功能。
相关问题
写一个阿里云DDNS Linux脚本
好的,以下是一个阿里云DDNS的Linux脚本:
```
#!/bin/bash
# 阿里云DDNS脚本
# 请替换以下变量
AK="your_access_key_id"
SK="your_access_key_secret"
DomainName="your_domain_name"
RR="your_RR"
# 获取公网IP
IP=`curl -s http://ipecho.net/plain`
# 获取当前DNS记录
RecordId=`curl -s http://alidns.aliyuncs.com/?Action=DescribeSubDomainRecords&AccessKeyId=$AK&SignatureMethod=HMAC-SHA1&SignatureNonce=$RANDOM&SignatureVersion=1.0&Timestamp=$(date -u "+%Y-%m-%dT%H%%3A%M%%3A%SZ")&Version=2015-01-09&Signature=$(echo -n "GET&%2F&AccessKeyId%3D$AK%26Action%3DDescribeSubDomainRecords%26DomainName%3D$DomainName%26RRKeyWord%3D$RR%26SignatureMethod%3DHMAC-SHA1%26SignatureNonce%3D$RANDOM%26SignatureVersion%3D1.0%26Timestamp%3D$(date -u "+%Y-%m-%dT%H:%M:%SZ")%26Version%3D2015-01-09" | openssl sha1 -hmac "$SK&" -binary | base64)`
RecordId=`echo $RecordId | awk -F '"' '/RecordId/{print $4}'`
# 判断DNS记录是否存在,如果存在则更新,否则创建
if [ "$RecordId" != "" ]; then
curl http://alidns.aliyuncs.com/?Action=UpdateDomainRecord&AccessKeyId=$AK&SignatureMethod=HMAC-SHA1&SignatureNonce=$RANDOM&SignatureVersion=1.0&Timestamp=$(date -u "+%Y-%m-%dT%H%%3A%M%%3A%SZ")&Version=2015-01-09&RecordId=$RecordId&RR=$RR&Type=A&Value=$IP&Signature=$(echo -n "GET&%2F&AccessKeyId%3D$AK%26Action%3DUpdateDomainRecord%26DomainName%3D$DomainName%26RR%3D$RR%26RecordId%3D$RecordId%26SignatureMethod%3DHMAC-SHA1%26SignatureNonce%3D$RANDOM%26SignatureVersion%3D1.0%26Timestamp%3D$(date -u "+%Y-%m-%dT%H:%M:%SZ")%26Type%3DA%26Value%3
windows加固脚本_Linux主机自动加固脚本
对于 Windows 主机加固,可以使用以下脚本:
```
# 关闭不必要的服务
sc stop wuauserv
sc config wuauserv start=disabled
sc stop RemoteRegistry
sc config RemoteRegistry start=disabled
sc stop SSDPSRV
sc config SSDPSRV start=disabled
# 禁用不必要的端口
netsh advfirewall firewall add rule name="Block Port 135" dir=in action=block protocol=TCP localport=135
netsh advfirewall firewall add rule name="Block Port 137" dir=in action=block protocol=UDP localport=137
netsh advfirewall firewall add rule name="Block Port 138" dir=in action=block protocol=UDP localport=138
netsh advfirewall firewall add rule name="Block Port 139" dir=in action=block protocol=TCP localport=139
netsh advfirewall firewall add rule name="Block Port 445" dir=in action=block protocol=TCP localport=445
# 修改本地策略
secedit /export /cfg C:\secpol.cfg
(Get-Content C:\secpol.cfg).replace("PasswordComplexity = 1", "PasswordComplexity = 0") | Set-Content C:\secpol.cfg
secedit /configure /db %windir%\security\local.sdb /cfg C:\secpol.cfg /areas SECURITYPOLICY
# 禁止自动运行
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v "NoAutoplayfornonVolume" /t REG_DWORD /d "1" /f
# 禁用 SMBv1
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" SMB1 -Type DWORD -Value 0 -Force
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters" SMB1 -Type DWORD -Value 0 -Force
```
对于 Linux 主机加固,可以使用以下脚本:
```
# 更新系统
yum update -y
# 禁用不必要的服务
systemctl stop xinetd
systemctl disable xinetd
systemctl stop avahi-daemon.socket avahi-daemon.service
systemctl disable avahi-daemon.socket avahi-daemon.service
systemctl stop cups.socket cups.service
systemctl disable cups.socket cups.service
# 设置防火墙
firewall-cmd --zone=public --add-port=22/tcp --permanent
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=443/tcp --permanent
firewall-cmd --reload
# 修改SSH设置,禁用root登录
sed -i 's/#PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/sshd_config
systemctl restart sshd
# 安装 SELinux
yum install selinux-policy selinux-policy-targeted -y
```
以上脚本仅供参考,具体根据实际情况进行修改和调整。
阅读全文