N天学习一个linux命令之ssh-keygen
用途
生成ssh加密算法需要使用到的秘钥以及管理和转换
用法
ssh-keygen [-q] [-b bits] -t type [-N new_passphrase] [-C comment] [-f output_keyfile]
ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]
ssh-keygen -i [-f input_keyfile]
ssh-keygen -e [-f input_keyfile]
ssh-keygen -y [-f input_keyfile]
ssh-keygen -c [-P passphrase] [-C comment] [-f keyfile]
ssh-keygen -l [-f input_keyfile]
ssh-keygen -B [-f input_keyfile]
ssh-keygen -D pkcs11
ssh-keygen -F hostname [-f known_hosts_file] [-l]
ssh-keygen -H [-f known_hosts_file]
ssh-keygen -R hostname [-f known_hosts_file]
ssh-keygen -r hostname [-f input_keyfile] [-g]
ssh-keygen -G output_file [-v] [-b bits] [-M memory] [-S start_point]
ssh-keygen -T output_file -f input_file [-v] [-a num_trials] [-W generator]
ssh-keygen [-n] [-D smartcard]
ssh-keygen -s ca_key -I certificate_identity [-h] [-Z principals] [-O option] [-V validity_interval]
[-z serial_number] file ...
ssh-keygen -L [-f input_keyfile]
常用选项
-B
显示秘钥文件的bubblebabble摘要
-b bits
秘钥长度,长度越长,加密越安全,默认是2048个比特
-C comment
设置注释
-c
请求修改备注,只支持RSA1算法的秘钥文件,如果文件设置了密码,会提示输入密码
-D pkcs11
下载存储在pkcs11的RSA公钥
-e
读取OpenSSH公钥文件内容,转换成RFC 4716 SSH Public Key File Format格式,然后输出到stdout
-F hostname
从known_hosts文件查找hostname,没有指定文件,默认查找~/.ssh/known_hosts。只能查找域名,ip查询不了。
-f filename
指定秘钥文件完整路径
-G output_file
(Generate candidate primes for DH-GEX. These primes must be screened for safety (using the -T option) before use.)
-g
(Use generic DNS format when printing fingerprint resource records using the -r command.)
-H
(Hash a known_hosts file. This replaces all hostnames and addresses with hashed representations within the specified file; the original content is moved to a file with a .old suffix. These hashes may be used normally by ssh and sshd, but they do not reveal identifying information should the file’s contents be disclosed. This option will not modify existing hashed hostnames and is therefore safe to use on files that mix hashed and non-hashed names.)
-h
(When signing a key, create a host certificate instead of a user certificate.)
-I
(Specify the key identity when signing a public key.)
-i
(This option will read an unencrypted private (or public) key file in SSH2-compatible format and print an OpenSSH compatible private (or public) key to stdout.)
-L
输出证书的内容
-l
显示公钥指纹
-M memory
(Specify the amount of memory to use (in megabytes) when generating candidate moduli for DH-GEX.)
-n
(Extract the public key from smartcard.)
-N new_passphrase
设置文件密码
-P passphrase
(Provides the (old) passphrase.)
-p
请求修改文件密码
-q
安静模式
-R hostname
(Removes all keys belonging to hostname from a known_hosts file.)
-r hostname
(Print the SSHFP fingerprint resource record named hostname for the specified public key file.)
-s ca_key
(Certify (sign) a public key using the specified CA key.)
-t type
设置创建的秘钥类型.
(The possible values are “rsa1” for protocol version 1 and “dsa”, “ecdsa” or “rsa” for protocol version 2.)
-v
调试模式
-y
(This option will read a private OpenSSH format file and print an OpenSSH public key to stdout.)
实践
1 提取符合标准格式的公钥
[root@vm ssh]# ssh-keygen -e -f ssh_host_rsa_key
---- BEGIN SSH2 PUBLIC KEY ----
Comment: "2048-bit RSA, converted from OpenSSH by root@vm"
AAAAB3NzaC1yc2EAAAABIwAAAQEAvF/iYFaWAMBMdAA4888pq1uxL34ptaEci/H0aG21eW
eloNtM/QPx8DiSTOcF7rT/i0BLMBAzNKdSZOZHBdG8Apf5VWsfNyKQ6a5qEfV26lr6CKg8
zPgdLoA8bQYarjN+LKrYWT9xteafVw9TLAtQAAdZFePkUkIKBMVhn48kM95HHOF6hcua99
TcJ0AyvcFof+ebLyGznXKxrf2sliAHwaCWwO7rHhuIRJvCyDmrzh4NffozRqVfJEm2c90H
3397Nd6seCOHOUVNRz2l69hfYWOPuuvlS2aQicbU9touw5f4ZvDTFxpyn2ZvqGaZzvBril
/QF/qbEsKYsCVCWaUYMQ==
---- END SSH2 PUBLIC KEY ----
2 查找github.com主机key信息
[root@vm ssh]# ssh-keygen -H -F github.com
# Host github.com found: line 5 type RSA
|1|+31fGJzfnYKj7Mzk9ncYS2pZ7sI=|C0orBfR1oH2VQ9ij2gRz9QBOAyk= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg733www+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
3 显示公钥指纹
[root@vm ssh]# ssh-keygen -l -f ./ssh_host_rsa_key.pub
2048 90:05:de:31:8c:ff:ba:5a:2b:b3:80:b5:61:68:52:52 ./ssh_host_rsa_key.pub (RSA)
4 生成rsa公私钥
[root@vm ~]# ssh-keygen -v -b 2048 -t rsa -C "rsa key file ,just a test" -f ./test_key
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in ./test_key.
Your public key has been saved in ./test_key.pub.
The key fingerprint is:
f0:66:15:6d:cd:cb:e7:d2:b9:ce:b5:dc:44:ff:97:f0 rsa key file ,just a test
The key's randomart image is:
+--[ RSA 2048]----+
| .. o |
| .o o |
| . .. . . |
| o . o .|
| S +o|
| o ..o+|
| o.*|
| oE*|
| .=+|
+-----------------+
参考资料
【1】man ssh-keygen
N天学习一个linux命令之ssh-keygen的更多相关文章
- N天学习一个linux命令之ssh
用途 通过加密连接,远程登录主机和在远程主机执行命令,也可以用于转发x11和tcp,也可用于搭建VPN.第一次连接时,会弹出远程主机公钥指纹确认信息,通过这个方式防止中间人攻击. 用法 ssh [op ...
- N天学习一个Linux命令之帮助命令:man
前言 工作中每天都在使用常用的命令和非常用的命令,忘记了用法或者参数,都会bing一下,然后如此循环.一直没有真正的系统的深入的去了解命令的用法,我决定打破它.以前看到有人,每天学习一个linux命令 ...
- N天学习一个linux命令之scp
用途 通过ssh通道,不同主机之间复制文件 用法 scp [options] [user@host:]file1 [user2@host2:]file2 常用参数 -1使用 ssh 1协议 -2使用s ...
- N天学习一个Linux命令之free
用途 查看系统内存(物理/虚拟/缓存/共享)使用情况 用法 free [-b | -k | -m | -g | -h] [-o] [-s delay ] [-c count ] [-a] [-t] [ ...
- N天学习一个linux命令之ping
用途 检测主机是否可到达,也就是说,目标主机是否可以联网,还可以用于检测网速.通过发送ICMP ECHO_REQUEST数据包检测. 用法 ping [options] destination 常用选 ...
- N天学习一个linux命令之kill
用途 用于终止进程 用法 kill [-s signal|-p] [--] pid... kill -l [signal] 说明 1.默认发送信号15(请求终止进程,程序可以捕获,操作系统会杀死没有对 ...
- N天学习一个linux命令之du
用途 统计文件或者目录占用硬盘空间大小 用法 du [OPTION] [FILE]du [OPTION] --files0-from=F 常用参数 -a, --all统计所有文件,不仅仅是目录 -b, ...
- 每天学习一个Linux命令-目录
在工作中总会零零散散使用到各种Linux命令,从今天开始详细的学习一下linux常用命令,坚持每天一个命令,学习的主要参考资料为: 1.竹子-博客(https://www.cnblogs.com/pe ...
- N天学习一个linux命令之umask
前言 umask不是linux命令,而是shell内置的指令,俗称用户权限掩码,用于对用户创建的文件和目录设置默认权限.默认的权限掩码是0022,也就是说新创建的文件权限是0644,新创建的目录权限是 ...
- N天学习一个linux命令之ip
用途 show / manipulate routing, devices, policy routing and tunnels 用法 通用格式 ip [ OPTIONS ] OBJECT { CO ...
随机推荐
- [Swift通天遁地]九、拔剑吧-(6)使用开源类库快速搭建强大的侧边栏项目
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- 如何获取<a>标签的Id
案例: <a id='213' href='javascript:void(0);'onclick=DealFun(this.Id);>删除</a> 解决方案: functio ...
- Offer收割_4
1.水题 2.BFS宽搜(使用优先队列priority_queue) 4.题意:给数组a.要求重排列数组,使得数组中的任意相邻的两个元素不同.如果存在多个方案,那么选择字典序最小的方案. 如果不能满 ...
- [转]linux uniq 命令详解
转自:http://blog.csdn.net/tianmohust/article/details/6997683 uniq 命令 文字 uniq 是LINUX命令 用途 报告或删除文件中重复的 ...
- windows server 2008 r2 安裝IE11
https://support.microsoft.com/en-us/help/2847882/prerequisite-updates-for-internet-explorer-11 https ...
- 转 IDEA 解决代码提示功能消失
转载路径是 https://blog.csdn.net/hmily_hui/article/details/78213037 原文地址:https://github.com/Damao/Intell ...
- Lazarus Reading XML- with TXMLDocument and TDOMNode
这里读取'HistoryPath' ,'TracePath' 元素下的‘value’属性使用的是 var xmlCfg: TXMLDocument; .... function ReadXMLCFG: ...
- centos设置ssh安全只允许用户从指定的IP登陆
1.编辑文件 /etc/ssh/sshd_config vi /etc/ssh/sshd_config 2.root用户只允许在如下ip登录 AllowUsers root@203.212.4.117 ...
- iOS 中plist文件中配置key值冲突的现象
iOS开发一些特殊的软件需要在项目中配置对应的key值,然而近期在项目中发现一个有意思的现象,苹果官方文档中提供的key值很多,但其实有一些彼此可能有冲突,当你同时配置了彼此冲突的key值,可能会出现 ...
- P1886 滑动窗口&&P1440 求m区间内的最小值
声明:下面这两个题就不要暴力了,学一学单调队列吧 推荐博文:https://www.cnblogs.com/tham/p/8038828.html 单调队列入门题 P1440 求m区间内的最小值 题目 ...