SSH

创建 SSH 密钥对

ssh-keygen -t ed25519 -C "用户名@备注信息"

引号中内容为备注信息,可以任意填写

默认保存路径 ~/.ssh/ , 私钥: ~/.ssh/id_ed25519 , 公钥: ~/.ssh/id_ed25519.pub

在不支持ed25519 算法的老旧系统中生成密钥
ssh-keygen -t rsa -b 4096 -C "用户名@备注信息"

SSH 配置文件

连接保活,每60秒发送一个 keep-alive 包

cat ~/.ssh/config

ServerAliveInterval 60

# 开启ssh-agent转发
Host *
    ForwardAgent yes

# 针对特定主机开启 ssh-agent 转发
Host github
    HostName github.com
    IdentityFile ~/.ssh/id_ed25519
    User git
    ForwardAgent yes
eval `ssh-agent -s`
ssh-add
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9