Category: Uncategorized

  • SSH Login delay

    SSH Login delay

    When i login to a server, SSH connection take more than 2 minutes.

    boby@sok-01:~$ time ssh root@10.10.1.1 -p 3333 exit
    
    real	2m7.288s
    user	0m0.120s
    sys	0m0.039s
    boby@sok-01:~$

    In the server, i disbled UseDNS in /etc/ssh/sshd_config

    UseDNS no

    This was AlmaLinux server 9 with GSSAPIAuthentication disabled, DIsabled with GSSAPIAuthentication with

    cat > /etc/ssh/sshd_config.d/10-tweaks.conf << 'EOF'
    GSSAPIAuthentication no
    GSSAPICleanupCredentials no
    EOF
    
    systemctl restart sshd

    Verified it is disabled with

    sshd -T | grep -iE "gssapi|pam|usedns|pubkey|password"

    When running

    journalctl -u sshd -f

    Got the error “PAM Error connecting to /opt/i360_pam_imunify/pam_imunify360.sock: Connection refused”, this is resolved by updating immunify360

    wget -O imunify-force-update.sh https://repo.imunify360.cloudlinux.com/defence360/imunify-force-update.sh 
    bash imunify-force-update.sh

    Once this is done, pam related error disappear, but the login still takes time, I got it resolved by running

    systemctl daemon-reload
    systemctl restart systemd-logind

    To see systemd-logind related logs run

    journalctl -u systemd-logind --since "5 minutes ago"

    sshd pam config located in

    cat /etc/pam.d/sshd
  • cPanel Disk Quota

    cPanel Disk Quota

    To see the disk quota for a user, run

    quota -vs USERNAME

    To see disk used by a cpanel user, run

    cd /home/USERNAME
    du -h --max-depth=1

    To see MySQL usage, run

    du -sh /var/lib/mysql/USERNAME*

    To see list of files for a user

    find / -user USERNAME -ls
    find / -user USERNAME -type f -size +100M

    cpanel scripts

    /scripts/fixquotas
    /scripts/generate_maildirsize --force --allaccounts

    Back to Cpanel Server

  • Teaching SpamAssassin What Is Spam

    Teaching SpamAssassin What Is Spam

    SpamAssassin is one of the most widely used open-source spam filtering systems for email servers. It is commonly deployed together with Postfix (mail transfer) and Dovecot (mail delivery / IMAP).

    Instead of relying on a single rule, SpamAssassin assigns a spam score to every email based on hundreds of tests, including:

    • Header analysis
    • Body content checks
    • DNS blocklists (RBLs)
    • SPF, DKIM and DMARC results
    • Bayesian (statistical) analysis

    When the score exceeds a configured threshold, the message is marked or delivered as spam.

    Teaching SpamAssassin What Is Spam

    SpamAssassin provides the sa-learn command to train its Bayesian database.

    To teach SpamAssassin that emails in a Junk folder are spam, you run:

    sa-learn --spam /home/USER/Maildir/.Junk\ E-mail/{cur,new}

    SpamAssassin automatically ignores messages it has already learned, so running this command multiple times is safe.

    Teaching SpamAssassin What Is NOT Spam (Ham)

    Training spam alone is not enough. For best accuracy, SpamAssassin should also learn from legitimate mail (ham), usually from the Inbox:

    sa-learn --ham /home/USER/Maildir/{cur,new}

    A healthy Bayesian database contains both spam and ham, ideally at least a few thousand messages of each.

    Back to SpamAssassin

  • iotop

    iotop

    iotop shows which process is doing disk I/O.

    Shows only tasks doing I/O:

    iotop -oPa

    -o toggles “only active I/O”
    -a accumulates I/O per process
    -P shows per-process (not threads)

    If you get SWAPIN/IO% warning, run

    sysctl -w kernel.task_delayacct=1

    Server Load

  • Alpine Linux

    Alpine Linux

    Alpine Linux is a lightweight, security-focused Linux distribution renowned for its simplicity, small footprint, and performance. Designed for power users, developers, and container environments, Alpine offers a minimal base system and uses the efficient APK package manager to handle software installation and updates.

    To install a package, use

    apk add PKG_NAME

    To list all package, use

    apk search PKG_NAME

    Example

    test-alpine:~# apk search strongswan
    aconf-mod-strongswan-0.8.1-r4
    strongswan-5.9.14-r0
    strongswan-dbg-5.9.14-r0
    strongswan-doc-5.9.14-r0
    strongswan-logfile-5.9.14-r0
    strongswan-openrc-5.9.14-r0
    test-alpine:~# 

    To start a service

    rc-service sshd start

    To start a service on boot

    rc-update add sshd

  • How to Upgrade Debian 11 to Debian 12

    How to Upgrade Debian 11 to Debian 12

    Refresh package lists and upgrade all installed packages:

    sudo apt update && sudo apt upgrade -y
    sudo apt full-upgrade
    sudo apt autoremove

    Reboot to ensure all updates are properly applied:

    reboot

    Change repository references in /etc/apt/sources.list from “bullseye” to “bookworm”.

    deb http://deb.debian.org/debian/ bookworm main
    deb-src http://deb.debian.org/debian/ bookworm main
    deb http://security.debian.org/debian-security bookworm-security main contrib
    deb-src http://security.debian.org/debian-security bookworm-security main contrib
    deb http://deb.debian.org/debian/ bookworm-updates main contrib
    deb-src http://deb.debian.org/debian/ bookworm-updates main contrib

    Update the package index and commence the upgrade:

    sudo apt update
    sudo apt upgrade -y
    sudo apt full-upgrade

    Remove obsolete packages and reboot for changes to take effect:

    sudo apt autoremove
    sudo reboot

    Back to Debian

  • Migrate CentOS Stream 8 to AlmaLinux 8

    Migrate CentOS Stream 8 to AlmaLinux 8

    First upgrade packages on CentOS Stream 8 server to latest version.

    dnf update

    Download AlmaLinux 8 migration script

    curl -O https://raw.githubusercontent.com/AlmaLinux/almalinux-deploy/master/almalinux-deploy.sh

    Run the migration script

    sudo bash almalinux-deploy.sh -d

  • How to make Linux History readonly

    How to make Linux History readonly

    To disallow normal linux users from changing environment variable HISTFILE, create a file

    vi /etc/profile.d/readonly_history.sh

    Add following content to the file:

    if [[ -n $BASH_VERSION ]]; then
      HISTTIMEFORMAT="%F %T "
      HISTFILE=~/.bash_history
      HISTCONTROL=
      # append to the hsitory file, don't overwrite it
      shopt -s histappend
      # save all lines of a multiple-line command in the same history entry
      shopt -s cmdhist
      # write commands to .bash_history immediately instead of at session end
      PROMPT_COMMAND="history -a"
      # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
      HISTSIZE=65536
      HISTFILESIZE=65536
      readonly HISTTIMEFORMAT
      readonly HISTFILE
      readonly HISTCONTROL
      readonly HISTSIZE
      readonly HISTFILESIZE
    fi

    Back to history

  • How to Run Docker Inside an LXD Container

    How to Run Docker Inside an LXD Container

    if you run docker inside an LXD container, it will fail with following error message

    root@sok-nodejs:~# docker run hello-world
    Unable to find image 'hello-world:latest' locally
    latest: Pulling from library/hello-world
    e6590344b1a5: Pull complete 
    Digest: sha256:c41088499908a59aae84b0a49c70e86f4731e588a737f1637e73c8c09d995654
    Status: Downloaded newer image for hello-world:latest
    docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "cgroup" to rootfs at "/sys/fs/cgroup": mount cgroup:/sys/fs/cgroup (via /proc/self/fd/6), flags: 0xf: permission denied: unknown.
    root@sok-nodejs:~# 

    To fix this, run following command on the host machine

    lxc config set <your-container-name> security.nesting true
    lxc restart <your-container-name>

    Example

    root@ns5028044:~# lxc config set sok-nodejs security.nesting true
    root@ns5028044:~# lxc restart sok-nodejs
    root@ns5028044:~# 

    Back to LXD

  • AI Code Assistants: From No-Code to Full Control

    AI Code Assistants: From No-Code to Full Control

    AI code assistants are rapidly transforming how we build software, making development accessible to everyone—from complete beginners to seasoned engineers. In 2025, the landscape is rich with tools offering varying degrees of control, collaboration, and production readiness. Here’s a breakdown of the top platforms, their strengths, and how to choose the right assistant for your needs.

    PlatformLevel of ControlIdeal User Type
    LovableBasic controlNon-technical
    Bolt / V0Code tweakingNon-technical
    ReplitFile managementProduct-minded, non-technical
    Tempo / OnlookDesign controlProduct-minded, non-technical
    Windsurf / Trae / CursorFull code controlTechnical

    Replit

    Bridges the gap between no-code and full-code. You can manage files, collaborate in real-time, and deploy instantly. Its conversational AI can generate full-stack apps from a prompt, but you can also dive into the code as needed

    https://replit.com

    Bolt

    Offers a browser-based coding sandbox with AI-powered suggestions, supporting a wide range of frameworks. You can start with templates or customize your tech stack, making it suitable for both beginners and those wanting a bit more control

    https://bolt.new

    V0

    V0 by Vercel is a platform designed to help users ship projects faster. It allows users to input prompts like “Clone a Screenshot” or “Landing Page” to generate project code. V0 also allows users to import designs from Figma. The platform showcases a variety of community-built projects, ranging from landing pages and dashboards to interactive components and games, providing a wide array of examples and starting points for users.

    https://v0.dev

    OnLook

    Onlook is a design tool that allows users to build website interfaces with AI. It enables designers to prompt AI to generate code, adjust layouts, change colors, and modify text, with no setup required. Onlook integrates with existing design systems and offers features such as version control, local code storage, and open-source support.

    https://onlook.com

    Lovable

    Perfect for those who want to build apps without writing any code. Just describe your idea, and Lovable generates a working application, letting you tweak design elements with simple clicks or chat prompts.

    https://lovable.dev

    Tempo Labs

    Focused on visual, design-driven editing. With live previews and AI-powered selectors, you can make real-time UI changes and sync with GitHub for smooth collaboration—ideal for those who want hands-on design control without deep coding

    https://www.tempo.new

    Windsurf / Trae / Cursor

    For developers seeking full code control. Cursor, built on VS Code, offers AI-powered code suggestions, multi-line edits, and deep integration with your codebase. Windsurf goes further, acting as a collaborative coding agent to help break down complex projects and generate multi-file code

    Zed

    Zed is a high performance editor with AI capabilities like cursor, windsurf, etc.. it is open source and written is rust.

    Zend has free and paid plan, also allows you to use your own API key.

    https://zed.dev

  • Free WordPress Backup and Migration Plugins

    Free WordPress Backup and Migration Plugins

    WordPress Migration plugin migrate your WordPress site easily and fast, plugins are the best helper and it can be done with a few easy steps.

    Below is a detailed look at some of the best WordPress backup plugins available.

    Migrate Guru

    Migrate Guru is a popular WordPress backup, security, and migration plugin. One of the key benefits of using Migrate Guru is its simplicity, making it a user-friendly option for anyone, regardless of their technical expertise. Works with any host via FTP.

    https://wordpress.org/plugins/migrate-guru/

    UpdraftPlus

    UpdraftPlus is a WordPress free plugin used for backups, restoration, and migration of WordPress websites. It allows users to schedule automatic backups of their site’s files and database, store them in cloud services and easily restore their site if needed.

    https://wordpress.org/plugins/updraftplus/

    Duplicator

    Duplicator is a wordpress popular backup free plugin. It is often used for migrations designed to simplify the process of migrating, copying, backing up, and cloning your website.

    Easily transfer your site from one host to another or clone your site for development and testing purposes. Duplicator packages all your site’s files, themes, plugins, and database into a single archive, making migration seamless.

    https://wordpress.org/plugins/duplicator/

    BackWPup

    BackWPup is a WordPress backup plugin that allows users to create complete backups of their site. It offers scheduled automatic backups, database optimization, and site restoration features. The Pro version includes additional storage options, encryption, and priority support. BackWPup is designed to help users protect their WordPress sites against data loss due to crashes, hacks, or server failures.

    https://wordpress.org/plugins/backwpup/

    Total Upkeep

    Total Upkeep is a WordPress backup, restoration, and migration free plugin developed by BoldGrid. It allows you to create complete backups of site’s files, databases, and all associated data. Total Upkeep also includes features like fault protection, which detects and prevents failed updates, and site migration tools for moving websites between hosts.

    https://wordpress.org/plugins/boldgrid-backup/


  • How to Install Node.js on AlmaLinux 9

    How to Install Node.js on AlmaLinux 9

    AlmaLinux 9 provide node.js version 16. Other versions are available in AppStream repository.

    To view available node.js versions, run

    dnf module list nodejs

    example

    [root@sokal9 ~]# dnf module list nodejs
    Last metadata expiration check: 0:57:10 ago on Sat 22 Mar 2025 04:25:45 PM UTC.
    AlmaLinux 9 - AppStream
    Name                               Stream                             Profiles                                                             Summary                                      
    nodejs                             18                                 common [d], development, minimal, s2i                                Javascript runtime                           
    nodejs                             20                                 common [d], development, minimal, s2i                                Javascript runtime                           
    nodejs                             22 [e]                             common [d] [i], development, minimal, s2i                            Javascript runtime                           
    
    Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
    [root@sokal9 ~]# 

    To install node.js 22, run

    dnf module install nodejs:22/common

    If you need to install another version, you need to reset the installed module first

    dnf module reset nodejs:22/common

    Install another version of node.js

    dnf module install nodejs:20/common

    See Node.js