Liunx Server Command

Generate SSH secret key

SSH secret key is a secure log in to connect to the Linux system without transmitting sensetive data.

Basic usage

The following command will generate a ssh secret key using the encryption Type you choose. After you generate the key pair, there will be two files in your SSH directory (usually ~/.ssh).
id_rsa:private key
id_rsa.pub:public key

1
$ ssh-keygen -t ed25519 -C "your_email@example.com"

Upload key

You can use some remote file transfer tools such as sftp, etc.
Then run the following

1
$ cat your_public_key_dir >> ~/.ssh/authorized_keys

Parameter Introduction

-t encryption Type

Type Intro. Recommand
ed25519 New generation elliptic curve algorithm, secure + fast + short ⭐⭐⭐⭐⭐
rsa Tradition Algorithm ⚠️ No longer preferred
ecdsa Old ECC ⚠️ Controversial
dsa Abandoned ❌ Abandoned

-C Comment

Used to clarify whom The public key serves for.

-f Specify filename

1
$ ssh-keygen -t ed25519 -f ~/.ssh/github_ed25519 -C "github"

build:

1
$ ssh-keygen -t ed25519 -f ~/.ssh/github_ed25519 -C "github"

-a KDF cycle(Anti-violent cracking)

1
$ ssh-keygen -t ed25519 -a 100
  • The bigger nummber,the securer key.
  • default 16
  • Recommendation: around 100