Skip to content

Instantly share code, notes, and snippets.

@MarshalW
Last active April 8, 2024 06:56
Show Gist options
  • Save MarshalW/8afd72794dd4361052cdae84ea624905 to your computer and use it in GitHub Desktop.
Save MarshalW/8afd72794dd4361052cdae84ea624905 to your computer and use it in GitHub Desktop.
有关ssh key及其他token生成的命令

有关ssh key及其他token生成的命令

ssh-keygen 静默生成 ssh key

不需要输入passphrase。

默认~/.ssh/id_rsa:

ssh-keygen -t rsa -b 4096 -q -P '' <<< ""$'\n'"y" 2>&1 >/dev/null

指定路径

# rsa
ssh-keygen -t rsa -b 4096 -f ./config/id_rsa -q -P ""

# ed25519
ssh-keygen -o -t ed25519 -a 100 -f ./config/id_ed25519 -q -P ""

目前的用法

2024-4-8, 在当前用户 ~/.ssh/id_ed25519 文件生成密钥:

ssh-keygen -t ed25519

如果不想每次使用key都输入phase:

# 追加内容到~/.bashrc文件末尾
cat << EOF >> ~/.bashrc
# only input phase once.
if [ -z "\$SSH_AUTH_SOCK" ] ; then
  eval \$(ssh-agent)
fi
EOF

source ~/.bashrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment