Passwordless SSH One-Liner
Tony Metzidis

Tony Metzidis @tonymet

About: Developer and Engineering Manager. Mostly backend & cloud platforms. Currently node.js & golang. Also AWS CSA Associate

Location:
SF Bay Area
Joined:
Feb 9, 2019

Passwordless SSH One-Liner

Publish Date: Jun 25 '20
5 1

When you need to get your key onto another machine, and you don't want the silly login-logout-copy-paste nonsense. Do this:

$ cat ~/.ssh/id_rsa.pub | ssh pi@pihole3bplus.local bash -c "mkdir -p .ssh && cat >> .ssh/authorized_keys"

Don't have a key? Here's how to make one

ssh-keygen
# smash the enter button
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/tonymet/tmp/kaka.
Your public key has been saved in /Users/tonymet/tmp/kaka.pub.
The key fingerprint is:
SHA256:WXXXXX
The key's randomart image is:
+---[RSA 3072]----+
|o.+++=+*Bo=.     |
| . xxxxxxxxx . . |
|   xxxxxxxxx+ + .|
|  xxxxxxxxxx = . |
|     = .S . =    |
|      B    o .   |
|     + .         |
|      .          |
|                 |
+----[SHA256]-----+

Comments 1 total

  • Kostas Psarras
    Kostas PsarrasJun 25, 2020

    Maybe just:
    ssh-copy-id -i ~/.ssh/mykey user@host
    :)

Add comment