One-liners

Add ssht to Linux

April 17, 2019

I recently ran across ssht (via Stack Overflow, of course) when trying to figure out how to launch tmux automatically upon an SSH connection. Enter this into a BASH prompt (assuming /usr/bin/ is in your PATH), and you’ll be good to go to use ssht as a drop-in replacement for ssh! sudo curl https://raw.githubusercontent.com/brejoc/ssht/master/ssht -o /usr/bin/ssht && sudo chmod +x /usr/bin/ssht

Add GitHub SSH keys to authorized_user file

January 7, 2019

If you have an SSH key you regularly use elsewhere added to your GitHub account, this one-liner to get those public keys and add them to the ~/.ssh/authorized_keys file of your current machine. It will also create the ~/.ssh/authorized_keys file if your current machine doesn’t have one. Notice: Be sure to swap out $USERNAME for your GitHub username below! if ! [[ -f ~/.ssh/authorized_keys ]]; then touch ~/.ssh/authorized_keys; fi && curl https://github. ... Read more…

Disable IPv6 in Ubuntu 14.04 or 16.04

January 2, 2019

If you’d like to disable IPv6 for whatever reason on Ubuntu 14.04 or 16.04, give this one-liner a go: sudo /bin/su -c "echo -e '\nnet.ipv6.conf.all.disable_ipv6 = 1\nnet.ipv6.conf.default.disable_ipv6 = 1\nnet.ipv6.conf.lo.disable_ipv6 = 1' >> /etc/sysctl.conf" && sudo sysctl -p && cat /proc/sys/net/ipv6/conf/all/disable_ipv6 It will echo three lines to the end of /etc/sysctl.conf, reload sysctl, and then cat the file /proc/sys/net/ipv6/conf/all/disable_ipv6 to let you know if IPv6 has been disabled (1) or not (0). ... Read more…

Update a standalone ESXi server

November 27, 2018

Even though it’s not the proper way to do it in production, sometimes it’s just nice to be able to update ESXi from SSH, especially an individual instance at home or in a lab. First head over to the awesome list from Virten.net and copy the latest Image Profile name (or reference the table at VMware’s KB and do a little googling to find the Image Profile for the latest release) available for your hardware. ... Read more…

Reset authorized_keys permissions

July 19, 2018

Sometimes, you might find you are having odd issues using public keys on a Linux server. I usually end up editing files under the wrong account and mess up permissions. The solution might be to run this one-liner (really an adaptation of multiple commands, one-liner is a questionable name for this) as the user who you’re trying to log in to the server as (probably not root): chmod 700 $HOME/.ssh && chmod go-w $HOME $HOME/. ... Read more…

Generate SSH key

June 19, 2018

A quick one-liner to generate a secure SSH key in Bash