# 生成密钥 ssh-keygen -t ed25519 -C "netnr" # 服务器端配置公钥,拷贝客户端公钥 id_ed25519.pub 内容写入服务器 vi ~/.ssh/authorized_keys # 其它配置(以上配置完成已经可以了) # 文件权限要求 chmod 600 authorized_keys chmod 700 ~/.ssh # 查看或配置打开密钥登录功能,默认不需要修改配置 vi /etc/ssh/sshd_config # 禁用密码登录配置 PasswordAuthentication no systemctl restart sshd # 配置后重启服务 # VSCode 配置连接 ~/.ssh/config Host github.com User git Hostname github.com IdentityFile ~/.ssh/git_id_rsa # Host 别名 # HostName 主机名 # Port 端口 # User 用户名 # IdentityFile 密钥文件的路径