Backup files quick with Bash's brace expansion

Alright, here’s a quick trick that I use at least a few times a week. Problem Let’s say we have a file that we want to make a copy of for whatever reason. In this example we’re creating a backup of the SSH server config before modifying it: $ cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak This is fine and dandy, but a bit verbose… We’re writing the same string two times and to be frank, it’s not fun....

April 8, 2023 · 1 min · David Isaksson

Closing a stale SSH connection

Suppose you’re connected to a remote host with SSH and after a while the SSH session goes stale. The terminal is unresponsive and no keypress seem to take effect. There might be something with the network, the remote host is restarting or maybe your machine has been in hibernation, there could be multiple reasons for a stale session. The first solution that might come to mind is to just close the terminal emulator and create another one, but there is a better way....

April 4, 2023 · 2 min · David Isaksson

Downloading Jenkins artifacts via the CLI

Problem I recently needed to download an artifact from a Jenkins build to my remote dev machine. The remote machine has access to the Jenkins controller, so I just ran wget with the link. $ wget https://jenkins.local/job/.../artifact/my_artifact.tar.gz I got this back: HTTP request sent, awaiting response... 403 Forbidden 2023-04-02 17:43:27 ERROR 403: Forbidden. Jenkins required authentication… Solution API token To authenticate ourselves we need to supply username and an API token....

April 2, 2023 · 2 min · David Isaksson