...
This commit is contained in:
86
_archive/termuxinstall.sh
Normal file
86
_archive/termuxinstall.sh
Normal file
@@ -0,0 +1,86 @@
|
||||
#!/bin/bash
|
||||
set -ex
|
||||
|
||||
# Ensure script is executed in Termux
|
||||
if [ -z "$TERMUX_VERSION" ]; then
|
||||
echo "This script must be run in Termux. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Function to handle errors
|
||||
handle_error() {
|
||||
echo "Error: $1"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Update and upgrade packages using Termux package management
|
||||
echo "Updating package list and upgrading installed packages..."
|
||||
pkg update -y || handle_error "Failed to update package list"
|
||||
pkg upgrade -y || handle_error "Failed to upgrade packages"
|
||||
|
||||
# Install essential utilities
|
||||
echo "Installing utilities: mc, htop, wget, curl..."
|
||||
pkg install -y mc htop wget curl termux-gui-bash || handle_error "Failed to install utilities"
|
||||
|
||||
# Install OpenSSH SSH server
|
||||
echo "Installing OpenSSH SSH server..."
|
||||
pkg install -y openssh || handle_error "Failed to install OpenSSH"
|
||||
|
||||
# Define SSH port
|
||||
SSH_PORT=8022 # Termux default port
|
||||
|
||||
# Check and handle existing dropbear
|
||||
if command -v dropbear >/dev/null 2>&1; then
|
||||
echo "Found existing dropbear installation, removing..."
|
||||
if pgrep dropbear >/dev/null; then
|
||||
pkill dropbear || handle_error "Failed to stop dropbear"
|
||||
fi
|
||||
pkg uninstall -y dropbear || handle_error "Failed to uninstall dropbear"
|
||||
fi
|
||||
|
||||
# Setup SSH directory and authorized_keys
|
||||
SSHDIR="$HOME/.ssh"
|
||||
mkdir -p "$SSHDIR"
|
||||
chmod 700 "$SSHDIR"
|
||||
|
||||
# Add authorized key
|
||||
echo "Adding authorized SSH key..."
|
||||
AUTHKEYS="$SSHDIR/authorized_keys"
|
||||
echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIahWiRRm9cWAKktH9dndn3R45grKqzPC3mKX8IjGgH6 kristof@incubaid.com" > "$AUTHKEYS"
|
||||
chmod 600 "$AUTHKEYS"
|
||||
|
||||
# Set password non-interactively (Termux specific)
|
||||
echo "Setting default password..."
|
||||
export PASSWORD="planet007"
|
||||
(echo "${PASSWORD}"; echo "${PASSWORD}") | passwd || handle_error "Failed to set password"
|
||||
|
||||
# Start SSH server
|
||||
echo "Starting SSH server on port $SSH_PORT..."
|
||||
sshd -p $SSH_PORT || handle_error "Failed to start SSH server"
|
||||
|
||||
termux-setup-storage
|
||||
|
||||
|
||||
pkg install libgc rust
|
||||
|
||||
# Display the current IP address
|
||||
echo "Fetching IP address..."
|
||||
IP_ADDR=$(ifconfig 2>/dev/null | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' | head -n 1)
|
||||
if [ -z "$IP_ADDR" ]; then
|
||||
echo "Could not determine IP address automatically"
|
||||
echo "Please check your IP address manually using 'ip addr'"
|
||||
else
|
||||
echo "Your IP address is: $IP_ADDR"
|
||||
echo ""
|
||||
echo "SSH connection details:"
|
||||
echo " - Host: $IP_ADDR"
|
||||
echo " - Port: $SSH_PORT"
|
||||
echo " - Password: planet007"
|
||||
echo " - Key authentication is enabled"
|
||||
echo ""
|
||||
echo "Example SSH commands:"
|
||||
echo " With password: ssh user@$IP_ADDR -p $SSH_PORT"
|
||||
echo " With key: ssh -i /path/to/private/key user@$IP_ADDR -p $SSH_PORT"
|
||||
fi
|
||||
|
||||
echo "Setup completed successfully!"
|
Reference in New Issue
Block a user