同事给了个公钥证书文件pub,让做ssh的证书登录

pub内容如下:

ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOoPPzVZkUUTPEEFueJzAxxxxxxxxEjiaskInSoMzJjEuo0zMZHVK8UqQPlFQcXPnW2+GgYigL2Q=  

傻眼了一下,一般证书的公钥都是如下的格式:

ssh-rsa AAAAB3NzaC1......  

查了一下,这个pub key原来是这么gen出来的:

ssh-keygen -t ecdsa  

剩下就简单了,证书登录方法和rsa的做法一样,放入~/.ssh/authorized_keys即可

ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBOoPPzVZkUUTPEEFueJzAxxxxxxxxEjiaskInSoMzJjEuo0zMZHVK8UqQPlFQcXPnW2+GgYigL2Q= root@localhost  

就可以凭密码登录了。

远程最好配一下登录所使用的key,跟rsa gen出的id_pub.key区分开来

vi ~/.ssh/config  
Host g git.coding.net  
    HostName git.coding.net
    IdentityFile ~/.ssh/coding.key
    User root
comments powered by Disqus