Notes: Linux OS

Notes: Linux OS

Linux OS - Solutions Index

These are notes compiled to resolve issues when working with the Linux OS on servers or devices.

Technical Notes: Linux

Start ssh-agent if not already running and redirects output to the ssh_agent.log to prevent protocol errors.

This may resolve Cockpit Protocol Errors and issues where WinSCP cannot connect due to the rror: Received too large (1097295214 B) SFTP packet. Max supported packet size is 1024000 B. This error is typically caused by message printed from startup script (like .profile).

if [ -z "$SSH_AUTH_SOCK" ]; then
    # Save current stdout (fd 1) and stderr (fd 2)
    exec 3>&1 4>&2
    # Redirect stdout and stderr to ssh_agent.log
    exec 1>>ssh_agent.log 2>&1

    # Run ssh-agent and capture its output (which is now only going to the log)
    agent_out=$(ssh-agent -s)
    eval "$agent_out"
    ssh-add ~/.ssh/id_ed25519

    # Restore stdout and stderr
    exec 1>&3 2>&4
fi

Create an alias that uses Docker Compose to build and start an application container in the background.

alias deploystatusapi='cd /usr/share/nginx/status-api.cvad.unt.edu && \
ls && \
sudo docker compose up --build -d'