4

Linux之ssh-add命令

 3 years ago
source link: https://segmentfault.com/a/1190000040628558
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

ssh-add命令是把专用密钥添加到ssh-agent的高速缓存中,从而提高ssh的认证速度。该命令位置在/usr/bin/ssh-add。

ssh-add [-cDdLlXx] [-t life] [file ...]
ssh-add -s pkcs11
ssh-add -e pkcs11
  • -D:删除ssh-agent中的所有密钥.
  • -d:从ssh-agent中的删除密钥
  • -e pkcs11:删除PKCS#11共享库pkcs1提供的钥匙。
  • -s pkcs11:添加PKCS#11共享库pkcs1提供的钥匙。
  • -L:显示ssh-agent中的公钥
  • -l:显示ssh-agent中的密钥
  • -t life:对加载的密钥设置超时时间,超时ssh-agent将自动卸载密钥
  • -X:对ssh-agent进行解锁
  • -x:对ssh-agent进行加锁

开启ssh-agent

默认操作系统是不开启ssh-agent的,需要手动打开

> ssh-agent bash

把专用密钥添加到ssh-agent的高速缓存中

> ssh-add ~/.ssh/id_dsa

从ssh-agent中删除密钥

> ssh-add -d ~/.ssh/id_dsa.pub

查看ssh-agent中的密钥

> ssh-add -l

如果出现Could not open a connection to your authentication agent. 错误则需要先执行ssh-agent bash然后再执行ssh-add ~/.ssh/id_dsa

原文链接:https://rumenz.com/rumenbiji/...
微信公众号:入门小站


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK