2019-11-01发表2023-03-17更新基础2 分钟读完 (大约237个字)利用ssh密钥对的私钥访问服务器123456789101112131415161718192021222324252627282930<!--more-->------------ Server------------ 1. 创建密钥对ssh-keygen -t rsa -P ''2. 将私钥改为.pem格式openssl rsa -in .ssh/id_rsa -outform pem > dsjali.pem3. 修改权限,不然连接时会报错chmod 400 dsjali.pem4. 从私钥中产生公钥ssh-keygen -y -f dsjali.pem ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+5xBrPVEJ3mRo/yVFtSQSv1/J09oYHkbTD+l/4or04YqUCHJ7iR+A/LMeff0c9xKCbT9hsb/MvJGmCZGxuE375Fwu8XZGS8SfjYSxeh0uASOcZazOiBu4Ooegj9A3Ov4C9odPqISWbTdUx286WJqdzW7RZ0ZwkFOiproFrszAPnvg5xmlnMSa0afYgWhRXimmn2oyLt7PFfZIXX8PJnMs7x9B0+lwLLIVJRKrpU8if+gD80viC9wUJu3/jC1VF8Jg4Bq2aS7KiMX++LY1SKoOUUc0sHa/SFZEzuouaRGgrmU9XkM3DvzlfcrGN+/14WczAZG4st5. 将上面的公钥写入认证文件vim .ssh/authorized_keysssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC+5xBrPVEJ3mRo/yVFtSQSv1/J09oYHkbTD+l/4or04YqUCHJ7iR+A/LMeff0c9xKCbT9hsb/MvJGmCZGxuE375Fwu8XZGS8SfjYSxeh0uASOcZazOiBu4Ooegj9A3Ov4C9odPqISWbTdUx286WJqdzW7RZ0ZwkFOiproFrszAPnvg5xmlnMSa0afYgWhRXimmn2oyLt7PFfZIXX8PJnMs7x9B0+lwLLIVJRKrpU8if+gD80viC9wUJu3/jC1VF8Jg4Bq2aS7KiMX++LY1SKoOUUc0sHa/SFZEzuouaRGgrmU9XkM3DvzlfcrGN+/14WczAZG4st------------ Client------------1. 下载服务器上的.pem文件2. 连接ssh -i "dsjali.pem" [email protected]# .pem文件的权限为400,如果不是,可能报错。 利用ssh密钥对的私钥访问服务器https://python0.netlify.app/2019/11/01/利用ssh密钥对的私钥访问服务器/作者John Doe发布于2019-11-01更新于2023-03-17许可协议#ssh