Skip to content

Commit b7de5a9

Browse files
authored
Merge pull request #88 from buildplan/update_bashrc
Update .bashrc to use nano as default editor
2 parents 6f1b256 + 341afbe commit b7de5a9

3 files changed

Lines changed: 24 additions & 18 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
-----
99

10-
**Version:** v0.78.4
10+
**Version:** v0.78.5
1111

12-
**Last Updated:** 2025-11-27
12+
**Last Updated:** 2025-12-31
1313

1414
**Compatible With:**
1515

@@ -87,12 +87,12 @@ sha256sum du_setup.sh
8787

8888
Compare the output hash to the one below. They must match exactly.
8989

90-
`d7378f43082166cad26c7b232f3cd01e778a3377dea996c3f434e0f483317659`
90+
`efd2359032942499d8f59551ded16b0a9e45bda1c8748e0e17db0bc32c0a013b`
9191

9292
Or echo the hash to check, it should output: `du_setup.sh: OK`
9393

9494
```bash
95-
echo d7378f43082166cad26c7b232f3cd01e778a3377dea996c3f434e0f483317659 du_setup.sh | sha256sum --check
95+
echo efd2359032942499d8f59551ded16b0a9e45bda1c8748e0e17db0bc32c0a013b du_setup.sh | sha256sum --check
9696
```
9797

9898
### 3. Run the Script
@@ -130,7 +130,7 @@ sudo -E ./du_setup.sh --quiet
130130
| **Provider Package Cleanup** | Detects and optionally removes cloud provider packages, monitoring agents, and default provisioning users to reduce attack surface and unnecessary services. |
131131
| **System Compatibility Checks** | Verifies OS compatibility, root privileges, and internet connectivity. |
132132
| **Package Management** | Verifies root privileges, OS version compatibility, and internet connectivity. Prevents running on unsupported environments. |
133-
| **Setup User Creation & Management**| Creates or uses an existing admin user with optional SSH key setup and strong password enforcement. Includes marker file for cleanup exclusion. |
133+
| **Setup User Creation & Management** | Creates or uses an existing admin user with optional SSH key setup and strong password enforcement. Includes marker file for cleanup exclusion. |
134134
| **SSH Hardening and Rollback** | Disables root login, configures key-based authentication, sets custom SSH port, and supports rollback of SSH configuration if connectivity fails. |
135135
| **Firewall Setup** | Configures UFW to deny incoming traffic by default, allowing specific user-defined ports. |
136136
| **Fail2Ban Setup** | Configures Fail2Ban to monitor SSH and UFW logs, blocking suspicious IPs. |
@@ -139,7 +139,7 @@ sudo -E ./du_setup.sh --quiet
139139
| **Kernel and Sysctl Hardening** | Optional improvements to kernel parameters to mitigate common network attacks and improve system hardening. |
140140
| **Docker Install** | Installs Docker Engine and Docker Compose, then adds the admin user to the `docker` group. |
141141
| **Tailscale Setup** | Installs Tailscale and connects to a mesh network using a pre-auth key, with optional advanced flags. |
142-
| **Automated Remote Backup**| Sets up cron-driven `rsync` backup script to remote SSH servers, integrates with notifications and performs backup verification. |
142+
| **Automated Remote Backup** | Sets up cron-driven `rsync` backup script to remote SSH servers, integrates with notifications and performs backup verification. |
143143
| **Swap File Setup** | Creates an optional swap file with tuned `swappiness` and `vfs_cache_pressure` settings. |
144144
| **Security Auditing** | Runs optional **Lynis** and **debsecan** vulnerability audits and logs the results for review. |
145145
| **Logging and Reporting** | Logs all actions and generates a detailed report of setup and cleanup in `/var/log` and backup directories. Saves timestamped backups of modified configuration files in `/root/setup_harden_backup_*`. |

du_setup.sh

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/bin/bash
22

33
# Debian and Ubuntu Server Hardening Interactive Script
4-
# Version: 0.78.4 | 2025-11-27
4+
# Version: 0.78.5 | 2025-12-31
55
# Changelog:
6+
# - v0.78.5: Switched to using nano as the default editor in .bashrc.
67
# - v0.78.4: Improved configure_swap to detect swap partitions vs files.
78
# Prevents 'fallocate' crashes on physical partitions by offering to disable them or skip.
89
# - v0.78.3: Update the summary to try to show the right environment detection based on finding personal VMs and cloud VPS.
@@ -95,7 +96,7 @@
9596
set -euo pipefail
9697

9798
# --- Update Configuration ---
98-
CURRENT_VERSION="0.78.4"
99+
CURRENT_VERSION="0.78.5"
99100
SCRIPT_URL="https://raw.githubusercontent.com/buildplan/du_setup/refs/heads/main/du_setup.sh"
100101
CHECKSUM_URL="${SCRIPT_URL}.sha256"
101102

@@ -251,7 +252,7 @@ print_header() {
251252
printf '%s\n' "${CYAN}╔═════════════════════════════════════════════════════════════════╗${NC}"
252253
printf '%s\n' "${CYAN}║ ║${NC}"
253254
printf '%s\n' "${CYAN}║ DEBIAN/UBUNTU SERVER SETUP AND HARDENING SCRIPT ║${NC}"
254-
printf '%s\n' "${CYAN}║ v0.78.4 | 2025-11-27${NC}"
255+
printf '%s\n' "${CYAN}║ v0.78.5 | 2025-12-31${NC}"
255256
printf '%s\n' "${CYAN}║ ║${NC}"
256257
printf '%s\n' "${CYAN}╚═════════════════════════════════════════════════════════════════╝${NC}"
257258
printf '\n'
@@ -1101,8 +1102,8 @@ configure_custom_bashrc() {
11011102
if ! cat > "$temp_source_bashrc" <<'EOF'
11021103
# shellcheck shell=bash
11031104
# ===================================================================
1104-
# Universal Portable .bashrc for Modern Terminals
1105-
# Optimized for Debian/Ubuntu servers with multi-terminal support
1105+
# Universal Portable .bashrc
1106+
# For Debian/Ubuntu servers with multi-terminal support
11061107
# ===================================================================
11071108
11081109
# If not running interactively, don't do anything.
@@ -1260,12 +1261,12 @@ __bash_prompt_command() {
12601261
PROMPT_COMMAND=__bash_prompt_command
12611262
12621263
# --- Editor Configuration ---
1263-
if command -v vim &>/dev/null; then
1264-
export EDITOR=vim
1265-
export VISUAL=vim
1266-
elif command -v nano &>/dev/null; then
1264+
if command -v nano &>/dev/null; then
12671265
export EDITOR=nano
12681266
export VISUAL=nano
1267+
elif command -v vim &>/dev/null; then
1268+
export EDITOR=vim
1269+
export VISUAL=vim
12691270
else
12701271
export EDITOR=vi
12711272
export VISUAL=vi
@@ -1671,13 +1672,14 @@ alias ltr='ls -alFhtr' # Sort by modification time, oldest first
16711672
alias lS='ls -alFhS' # Sort by size, largest first
16721673
16731674
# Last command with sudo
1674-
alias please='sudo $(history -p !!)'
1675+
alias please='eval sudo "$(history -p !!)"'
16751676
16761677
# Safety aliases to prompt before overwriting.
16771678
alias rm='rm -i'
16781679
alias cp='cp -i'
16791680
alias mv='mv -i'
16801681
alias ln='ln -i'
1682+
alias mkdir='mkdir -p'
16811683
16821684
# Convenience & Navigation aliases.
16831685
alias ..='cd ..'
@@ -1727,7 +1729,10 @@ alias pscpu='ps auxf | sort -nr -k 3 | head -10'
17271729
alias top10='ps aux --sort=-%mem | head -n 11'
17281730
17291731
# Quick network info.
1730-
alias myip='curl -s ifconfig.me || curl -s icanhazip.com' # Alternatives: api.ipify.org, icanhazip.co
1732+
# Get public IP with timeouts (3s), fallbacks, and newline formatting
1733+
alias myip='curl -s --connect-timeout 3 ip.me || curl -s --connect-timeout 3 icanhazip.com || curl -s --connect-timeout 3 ifconfig.me; echo'
1734+
alias myip4='curl -4 -s --connect-timeout 3 ip.me || curl -4 -s --connect-timeout 3 icanhazip.com || curl -4 -s --connect-timeout 3 ifconfig.me; echo'
1735+
alias myip6='curl -6 -s --connect-timeout 3 ip.me || curl -6 -s --connect-timeout 3 icanhazip.com || curl -6 -s --connect-timeout 3 ifconfig.me; echo'
17311736
# Show local IP address(es), excluding loopback.
17321737
localip() {
17331738
ip -4 addr | awk '/inet/ {print $2}' | cut -d/ -f1 | grep -v '127.0.0.1'
@@ -1765,6 +1770,7 @@ if command -v docker &>/dev/null; then
17651770
alias d='docker'
17661771
alias dps='docker ps'
17671772
alias dpsa='docker ps -a'
1773+
alias dpsn="docker ps --format '{{.Names}}'"
17681774
alias dpsq='docker ps -q'
17691775
alias di='docker images'
17701776
alias dv='docker volume ls'

du_setup.sh.sha256

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d7378f43082166cad26c7b232f3cd01e778a3377dea996c3f434e0f483317659 du_setup.sh
1+
efd2359032942499d8f59551ded16b0a9e45bda1c8748e0e17db0bc32c0a013b du_setup.sh

0 commit comments

Comments
 (0)