Generate and Automatically Load SSH Keys for Convenient Passwordless Authentication

When correctly executed, public/private key authentication is more secure than shared secrets (passwords) for a number of reasons including but not limited to:

  • Disabling password-based authentication on remote hosts eliminates the potential for password brute-forcing.
  • Keyloggers installed on a local machine or keyboard firmware can only capture the key's passphrase as valid passwords for remote hosts are never typed.
  • A compromised, malicious, Man-in-the-Middle'd, DNS or ARP poisoned (and so on...) remote host can intercept passwords in the clear; a private key is a component in a randomized and unique cryptographic challenge and is never transmitted.
  • If a public key on a remote host is compromised or intercepted enumerating the private key is significantly more difficult (virtually impossible) than hash cracking/rainbow lookup.
  • Enforcing key authentication establishes a standard level of complexity regardless of users' choice in passwords.
  • One key can be used for any number of remote hosts under a variety of usernames permitting a diversity of remote-local account passwords and configurations.
  • Securing your private key with a password that only has to be entered once alleviates the influence of convenience in selecting a suitably complex password.

Note: It is a matter of personal policy that regardless of the method of authentication used, no management interface should be exposed to the wild wherever possible. Inherent in the term 0-day, there is always a potential for yet-unknown flaws in authentication methodology or any other part of the vast machinery of daemons and their host OS to come to light and render the most supposedly secure authentication scheme ineffective. Where full out-of-band administration is not possible I generally subscribe to an architecture wherein hosts are placed on a private internal network and only the essential public-facing ports are exposed to public address space by a firewall configured for DNAT (1-1 NAT). Access to management interfaces is obtained by VPN tunnel to the private network. Ideally VPN gateway services are provided by a separate host from the firewall - which should do nothing but firewall and itself expose no management interfaces to the wild. This has an added benefit of allowing one to "stack" services from multiple compartmentalized hosts (e.g. HTTP, SMTP, DNS) behind individual IPs, making more efficient use of (often costly) public address space.

Ten years ago I wrote an article for this site on how to implement Passwordless or Single Password SSH with Key Exchange. A lot has changed since then; most importantly ECDSA became available in 2011 and is now widely implemented.

From SSH.com https://www.ssh.com/ssh/keygen/:

SSH supports several public key algorithms for authentication keys. These include:

  • rsa - an old algorithm based on the difficulty of factoring large numbers. A key size of at least 2048 bits is recommended for RSA; 4096 bits is better. RSA is getting old and significant advances are being made in factoring. Choosing a different algorithm may be advisable. It is quite possible the RSA algorithm will become practically breakable in the foreseeable future. All SSH clients support this algorithm.
  • dsa - an old US government Digital Signature Algorithm. It is based on the difficulty of computing discrete logarithms. A key size of 1024 would normally be used with it. DSA in its original form is no longer recommended.
  • ecdsa - a new Digital Signature Algorithm standarized by the US government, using elliptic curves. This is probably a good algorithm for current applications. Only three key sizes are supported: 256, 384, and 521 (sic!) bits. We would recommend always using it with 521 bits, since the keys are still small and probably more secure than the smaller keys (even though they should be safe as well). Most SSH clients now support this algorithm.
  • ed25519 - this is a new algorithm added in OpenSSH. Support for it in clients is not yet universal. Thus its use in general purpose applications may not yet be advisable.

It should be noted that concerns over possible NSA tampering have been raised about the implementation of the NIST standardized P-curves used with ECDSA. EdDSA (Ed25519 which implements Curve25519 instead of P-curves) is purported to be faster than ECDSA in some cases. EdDSA became available in OpenSSH in 2014 and although we will use ECDSA for the purposes of this article due to its ubiquity, EdDSA is currently presumed to be as strong or stronger and you should feel free to use whichever you prefer. Take note that the maximum supported key size for ECDSA is 521 bits not 512. You may create additional keys using other algorithms to support older SSH daemons, however they should be updated if possible.

Use ssh-keygen to create the new key pair. The algorithm is specified by the -t flag and key size by -b:
ssh-keygen -t ecdsa -b 521 Generating public/private ecdsa key pair. Enter file in which to save the key (/home/user/.ssh/id_ecdsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/user/.ssh/id_ecdsa. Your public key has been saved in /home/user/.ssh/id_ecdsa.pub. The key fingerprint is: SHA256:Z7HOerLL3vT2D5/Sj3AFk27eUaLtDCgWnViY26OhosY [email protected] The key's randomart image is: +---[ECDSA 521]---+ | o. | | o+ . . | | oo+ = .| | o.o+ + +.| | .So=.o +..| | . ...* * o.| | . . . + . B .| | E ..+...+ =.| | . .*=....+o=| +----[SHA256]-----+ Alternatively... ssh-keygen -t ed25519 ssh-keygen -t rsa -b 4096 ssh-keygen -t dsa

It is important that you protect your private key with a strong passphrase: if the file is compromised an adversary will immediately have access to any accessible accounts without further obstacles. This is especially important if you wish to use the same private key on multiple hosts (e.g. your phone).

If you chose the default key file name your private key will be located at ~/.ssh/id_ecdsa and your public key will be located at ~/.ssh/id_ecdsa.pub. You may configure any number of keys by changing the filename when prompted or using the -f ssh-keygen flag from the command line.

Your public key must now be copied to the remote host(s) you wish to authenticate with. You may specify either the private or public key to ssh-copy-id using the -i flag as .pub will automatically be added to the filename if it is missing:
ssh-copy-id -i ~/.ssh/id_ecdsa [email protected]
Alternatively you may directly paste the public key (in this example, ~/.ssh/id_ecdsa.pub) into the ~/.ssh/authorized_keys file on the remote host. Use a text editor to modify the file to avoid the key being logged (e.g. in ~/.bash_history). A host can accept any number of keys; place them each on an individual newline. If you are manually creating the authorized_keys file for the first time or copying it from another host it is important to ensure that the correct file permissions are configured:
chmod 600 ~/.ssh/authorized_keys ls -lsah ~/.ssh/authorized_keys 4.0K -rw------- 1 user group 270 Apr 28 04:07 /home/user/.ssh/authorized_keys

Every time you connect to a host that supports your key you will be asked to enter the key's passphrase. To avoid this such that you only need to enter the password once, one must add it to the ssh-agent daemon. First, see if your system is already configured to load the daemon automatically:
ps aux | grep ssh-agent user 836 0.0 0.0 5852 2504 ? Ss May06 0:01 /usr/bin/ssh-agent
If it is not running you can launch it in the background thus:
eval "$(ssh-agent -s)"
You may wish to add this line to your preferred autorun script (i.e. /etc/rc.local, /etc/conf.d/local.start, ~/.xinitrc, etc.)

You can now manually add your key to the agent by:
ssh-add -K ~/.ssh/id_ecdsa
However this must be performed every time you restart ssh-agent (every time you reboot). A more permanent method is to create a ~/.ssh/config file with the following:
Host * AddKeysToAgent yes ForwardAgent yes UseKeychain yes IdentityFile ~/.ssh/id_ecdsa
Note: only include the highlighted UseKeychain directive on OS X. It will fail on other operating systems.

You may specify multiple IdentifyFile directives for additional keys. They will be attempted in the order they are listed. This is an ideal way to support multiple key algorithms. To use different keys for different hosts you are encouraged to create separate Host configurations, replacing the wildcard (*) with their remote address. Keys with supported algorithms but no corresponding public key on the remote host will count against your maximum failure attempts and may temporarily or indefinitely lock you out or trigger tools like fail2ban to firewall you.

It is possible to take advantage of the agent forwarding capability to maintain your private keys only on your local host but shell out from a remote host to another remote host with a valid public key matching one of the identities loaded in your local ssh-agent. To view the list of currently registered identities run:
ssh-add -l 521 SHA256:Z7HOerLL3vT2D5/Sj3AFk27eUaLtDCgWnViY26OhosY [email protected] (ECDSA)
To enable forwarding ForwardAgent must be set to yes (the default when unspecified is 'no') in the global default ssh_config client configuration file (/etc/ssh/ssh_config) or your user's personal config file (~/.ssh/config) either under the default (wildcard, "*") Host block or individually for specific hosts. The AllowAgentForwarding directive must be set to yes in the remote host's sshd_config server configuration file (/etc/ssh/sshd_config), which is the default value.

Once key authentication has been configured for all necessary users it is important to disable password-based authentication outright on your remote host(s). Edit /etc/ssh/sshd_config to reflect:
PasswordAuthentication no ChallengeResponseAuthentication no
Additionally, if you are not using PAM (if you are only using key authentication you are not) you may wish to also set UsePAM to no.

Leave a shell session open to ensure you are able to modify the configuration if you are configuring sshd remotely and something goes wrong. Restart sshd to effect the new configuration. Test to ensure you are still able to log in. Attempting to connect from a host with no valid keys configured should now produce:
Permission denied (publickey).

Favourite Browser Extensions

A short list of browser extensions I like to install so I don't have to go hunting when setting up a new machine:


  • uBlock Origin (note: uBlock sans Origin was acquired by AdBlock Plus and permits "acceptable ads" which they receive money for)
  • NoScript Security Suite
  • Privacy Badger
  • HTTPS Everywhere


  • uBlock Origin
  • ScriptSafe or NoScript (ScriptSafe has wider adoption on Chrome)
  • Privacy Badger
  • HTTPS Everywhere

Modify XFCE Window Manager Shadow (xfwm4)

I wasn't able to locate a GUI settings widget that would allow me to easily change the shadow settings in XFCE 4.12, part of the dom0 distributed with QubesOS. If I missed something or this has changed please let me know.

  • Open System Tools > Window Manager Tweaks
    • Click on the Compositor tab
    • Any time you adjust the following settings, check and uncheck the Show shadows under regular windows checkbox to preview/make your changes take effect.
  • Open System Tools > Settings Editor
    • Click on the xfwm channel. Scroll to the properties that begin with shadow_:
      • shadow_delta_height
      • shadow_delta_width
      • shadow_delta_x
      • shadow_delta_y
      • shadow_opacity

Things a Kratom Consumer Might Want to Know

I recently had a conversation with some nice folks imparting what little wisdom I have about Kratom after using it for 15 years - from the perspective of a consumer - and it came up that it could be useful to share this with other folks so here it is.

User 1, [23:42]
[In reply to karma]
I got tired of popping like 18 caps to get a good dosage.

User 2, [23:43]
I've thought about doing kratom. They have it in gas stations and some dispensaries around here. Is that stuff really that good???

User 1, [23:46]
[In reply to User 2]
Feels like a glorified caffeine to me

User 2, [23:48]
[In reply to User 1]
So I could essentially get the same effects from drinking a monster?

User 1, [23:48]
No 😂

User 1, [23:48]
Not quite

User 2, [23:48]
Plus there's so many different versions of it I don't even know which one is the best

User 1, [23:48]
Oh yeah lol, the different veins.

User 1, [23:48]
K would be more knowledgeable than me on that tbh

User 1, [23:49]
He could probably explain it better than I could too

User 2, [23:49]
I think he's messing with kratom right now

karma, [23:56]
it's not about the veins it's about the strains

karma, [23:56]
see i bought a kilo once

karma, [23:56]
i was like 18

karma, [23:56]
and it may as well have been bagged tea the lot of it

karma, [23:56]
i ate a whole oz over 3 hours and got nothing

karma, [23:57]
i'm not a pot strain kind of guy i don't pay any attention to them i just go by looks

karma, [23:57]
you can't do that with kratom powder

karma, [23:57]
so back in the day this one strain came around that was priced a buck an oz more across the board and they called it DA PIMPS KRATOM because kratom vendors of the era were rather unsophisticated

karma, [23:57]
you want that Maeng Da - if it is real it is always consistent. There may be better strains but if you want the old gold standard this is it.3

karma, [23:57]
doesn't really matter what vein

karma, [23:58]
i just got two kilos with 200g each of all different strains and veins. I have all sorts of different coloured veins of Maeng Da. People make a lot of fuss about the different effects of different colours. I have found that white/gold TEND to be the strongest but this is never always the case. Taste around and find the strain and vein that is right for you, but don't go by the bulls*** that "all red strains are 'more uplifting' and all green strains are 'more sedating'. This is f***ing nonsense marketing, kratom by and large is kratom. There is more potent kratom and less potent kratom and sure the alkaloid profiles are all different but the one we really care about bar none is mitragynine.

karma, [23:58]
some of them i've never tried before

karma, [23:58]
and i don't remember a lot of them because these days they come and go like pot strains

karma, [23:58]
but you can always rely on real Maeng Da to get you off on 7 grams

karma, [23:58]
that's all i'm taking at a time spaced throughout the day these days

karma, [23:58]
and i even get a little high

karma, [23:58]
if i wasn't an experienced user i would only need to do it once in the morning and i'd be high all day

karma, [23:58]
NOW. extracts.

karma, [00:00]
ok so tinctures: avoid them, except for the O.P.M.S mini liquid shots. these are expensive as f***, only available in america - or at least outside of canada because they are more "consumable" than the O.P.M.S branded gel caps but each one is tuned to about 110mg and there is your sweet spot. despite being expensive as f*** and tasting like an old man they are one of the quickest and least bulky (this is important) ways of getting your fix.

karma, [00:00]
raw leaf: HELL. NO. you do NOT want to make tea with this s***. that's just taking a horrible taste and making it go longer and it takes so many grams of raw powder to get off that, if you strained the tea it would take a litre and twice the plant material to get the same volume of alkaloids and if you didn't strain the tea you would literally be drinking kratom sludge. CAPSULES. ONLY. it is the ONLY worthwhile way of administering kratom.

karma, [00:00]
pure mitagynine extracts: nah. i have always found them weaker than full-spectrum. something about having the full alkaloid palette is important even though the amounts of the lesser two dozen alkaloids seems rather unimportant. also for some reason i have found these tend to induce the kratom migraine easier than other routes, other than tinctures.

karma, [00:00]
full spectrum mitagynine extracts: yes, but expensive, but how you want to get high without eating a s***load of caps if that is what is important to you.

karma, [00:00]
"enhanced strains": mmmyeah mostly

karma, [00:01]
this one notorious one came around called UEI for Ultra Enhanced Indo and i had such a good relationship with one of the only vendors that didn't f*** around with buttcoin and took manly credit cards that they eventually gave me a personalized discount code and then had me call them on their cell to order at a flat bulk rate

karma, [00:01]
this s*** was so good you could do one or two caps and get off for the whole day

karma, [00:01]
but it was a**PENSIVE

karma, [00:01]
but because it was so potent it was WORTH the idk 700 bucks an oz i was spending

karma, [00:02]
compare to regular kratom leaf powder at 10-13/oz

karma, [00:02]
what they do there is take mitragynine full spectrum extract and add it back to a bit of leaf powder

karma, [00:02]
for some reason this combination is harder hitting than just the extract and obviously s***tonnes harder than the plain leaf

karma, [00:02]
now a few years ago UEI disappeared much to the chagrin of the entire elite kratom using world. like this s*** had a reputation.

karma, [00:03]
but a bunch of people have started making enhanced extracts with all sorts of strains

karma, [00:03]

karma, [00:03]
because it's a hodgepodge, real UEI (there were fakes) used to come from only one distributor, it's buyer beware

karma, [00:03]
so if you go this route you want to get a couple grams of each one you want to try or you can rely on reviews that you can google up or reddit up or whatever the f*** ever

karma, [00:04]
then when you find your gal stick the f*** with her and try to get a bulk deal

User 1, [00:06]
I have a Kratom shop in my area so it was really simple for them to set me up with a pack of caps just because I'm a beginner

karma, [00:06]
ugggghhhh generally try to avoid brick and mortars for kratom

User 1, [00:06]
I was just trying it

User 1, [00:06]
I'm not as into it as you are lol

karma, [00:07]
they tend to have ridiculous markups and the commercial brands which are a very silly markup

karma, [00:07]
even if you are just trying it out you will probably find better ways from the comfort of your own home online

karma, [00:07]
ALSO you want to aim for ~110mg of mitragynine for a solid trip. but you should know about the kratom headache. obviously it varies by user but there is a ceiling to the dosing where you will end up with a debilitating headache and zero high.

User 2, [00:07]
It's better to buy it online?

karma, [00:07]
oh my yes

karma, [00:08]
brick and mortars especially just head shops are notorious for charging 3x for leaf powder and then there are the commercial brands which can be $60 for say 2 O.P.M.S gold capsules

karma, [00:08]
each capsule has the requisite mg in it to get you f***ed but you can get f***ed for sooooooo much less money even buying other extract based s*** online

karma, [00:08]
buy a bag of capsules it's your only hope

karma, [00:09]
if you buy anything precapped it will have a markup of at least 33% usually double

karma, [00:10]
now if you do get gel caps and you have found something you like if it is not an extract or enhanced leaf powder just straight leaf powder you need a capsule making machine because doing them all by hand will drive you mental

karma, [00:10]
on amazon there are new chinese fancy ones that do 100 at a time for $30

karma, [00:10]
i have one but it's more complicated to use than the two i have that i'm used to that's the old standard Cap-M-Quick "machine"

karma, [00:11]
this will make 50 capsules size 0 or 00 or if you get the model you really want size 00 or 000 within about 10 minutes

User 2, [00:11]
[In reply to karma]
How expensive is that?

User 1, [00:11]
I use the ole shove em in the caps with your finger method

karma, [00:11]
then you need to make sure you get the right size capsules off amazon

karma, [00:11]
gel caps are $30 a bag of 1000 on amazon

karma, [00:11]
you want the 000 ones if you are serious and want to save time

karma, [00:12]
[In reply to User 1]
ok i'm going to save your life here

karma, [00:13]
you fold a piece of paper and lay it back down flat. you dump the s*** in the middle and you take each half in each paw and you jam jam jam them together in the middle of the pile until they won't jam anymore. make sure there is some slack and then fix the capsule together. repeat. this is if you have enough powder for more than one capsule. otherwise take the paper and use the crease to sluice the material into the larger end of the capsule capsule

Install Telegram Messenger on a Qubes Fedora VM

Launch a terminal for the desired TemplateVM then enable the RPM Fusion repositories:
sudo bash dnf config-manager --set-enabled rpmfusion-free rpmfusion-nonfree dnf upgrade --refresh
Now install telegram-desktop
dnf install telegram-desktop

It should be noted that if you enable RPM Fusion repos and use KDE packages the version of Qt or KDE provided by Fusion will likely break virtually every KDE package except konsole and updating Qt amicably will eject Telegram. For this reason you should consider duplicating your Fedora TemplateVM before installing Telegram or using the RPM Fusion repos in general.

Don't forget to reduce your storage limits in the settings.