How to Copy Files to a Broken Linux Server
I recently began upgrading a Slackware Linux VPS using Linode. I thought I would upgrade OpenSSL to prevent GPG from crashing later. Bad move. It broke everything! Suddenly I had a broken server. I could not use SSHFS to copy a file, and didn’t have an FTP server running. I needed to get the proper packages onto the server, but how?
I came up with a clever solution. Download the packages locally. Encode the package file to base64 to turn it into text. Copy it to the clipboard. Finally, paste it into a text file on the server, decode it, and install the package.
First, you need to download the appropriate packages. I use Slackware, so went to packages.slackware.com. Go to the web site for your distribution. Find the package version closest to the version on your system. It needs to find all its required libraries. Download the file and encode it into base64. For example, to encode the file openssl-solibs-1.1.1za-x86_64-1.tgz, run a command such as:
base64 openssl-solibs-1.1.1za-x86_64-1.tgz > openssl-solibs-1.1.1za-x86_64-1.b64
This saves it to a file named openssl-solibs-1.1.1za-x86_64-1.b64. Copy it to your clipboard with:
xclip -selection clipboard openssl-solibs-1.1.1za-x86_64-1.b64
You can combine these two commands if you wish:
base64 openssl-solibs-1.1.1za-x86_64-1.tgz | xclip -selection clipboard
If for some reason you cannot encode the file locally, you may use www.base64encode.org.
Now you have a text encoded version copied to your clipboard. Go to your broken system and paste the contents into a file.
cat > openssl-solibs-1.1.1za-x86_64-1.b64
Paste with ctrl-shift-V or by selecting Edit | Paste in your terminal. Hit ctrl-d to end the file. Now decode it:
base64 -d openssl-solibs-1.1.1za-x86_64-1.b64 > openssl-solibs-1.1.1za-x86_64-1.tgz
And you will have the package, which you can install. In Slackware you would run:
installpkg openssl-solibs-1.1.1za-x86_64.tgz
For Debian and Ubuntu systems, run:
apt install openssl-solibs-1.1.1za.x86_64-1.deb
Redhat would use:
rpm -i openssl-solibs-1.1.1za.x86_64-1.rpm
Arch Linux would use:
pacman -U openssl-solibs-1.1.1za.x86_64-1.zst
and OpenSUSE would use:
zyp install openssl-solibs-1.1.1za.x86_64-1.rpm
And that should do it. Repeat the procedure for the other broken packages.
I hope this saves some poor sysadmin in a panic.