SSH Key生成及配置

2022-02-02 20:48:23 字數 3040 閱讀 6642

ssh是一種網路協議,用於計算機之間的加密登入。

個人常用

ssh-keygen -t rsa -f filename -c "[email protected]"

eg:

ssh-keygen -t rsa -f ~/.ssh/id_rsa.osc -c "[email protected]"

引數說明:-ttype金鑰型別(rsa、dsa...),-f生成檔名,-c備註

多個key的管理

在.ssh目錄下的config檔案中進行配置

host *.domain.com

identityfile filename

user username

eg:host git.oschina.net

identityfile ~/.ssh/id_rsa.osc

user buff

還有個檔案know_hosts,裡面會記錄每個你訪問過的機子的公鑰,如果你使用ssh登入出行衝突警告,可手動編輯或刪除該檔案

附:

usage: ssh-keygen [options]

options:

-a generate non-existent host keys for all key types.

-a trials number of trials for screening dh-gex moduli.

-b show bubblebabble digest of key file.

-b bits number of bits in the key to create.

-c comment provide new comment.

-c change comment in private and public key files.

-d pkcs11 download public key from pkcs11 token.

-e export openssh to foreign format key file.

-f hostname find hostname in known hosts file.

-f filename filename of the key file.

-g file generate candidates for dh-gex moduli.

-g use generic dns resource record format.

-h hash names in known_hosts file.

-h generate host certificate instead of a user certificate.

-i key_id key identifier to include in certificate.

-i import foreign format to openssh key file.

-j number screen this number of moduli lines.

-j number start screening moduli at specified line.

-k checkpt write checkpoints to this file.

-k generate a krl file.

-l print the contents of a certificate.

-l show fingerprint of key file.

-m memory amount of memory (mb) to use for generating dh-gex moduli.

-m key_fmt conversion format for -e/-i (pem|pkcs8|rfc4716).

-n phrase provide new passphrase.

-n name,... user/host principal names to include in certificate

-o option specify a certificate option.

-p phrase provide old passphrase.

-p change passphrase of private key file.

-q test whether key(s) are revoked in krl.

-q quiet.

-r hostname remove host from known_hosts file.

-r hostname print dns resource record.

-s start start point (hex) for generating dh-gex moduli.

-s ca_key certify keys with ca key.

-t file screen candidates for dh-gex moduli.

-t type specify type of key to create.

-u update krl rather than creating a new one.

-v from:to specify certificate validity interval.

-v verbose.

-w gen generator to use for generating dh-gex moduli.

-y read private key file and print public key.

-z serial specify a serial number.

本地生成 ssh key

1.配置git使用者名稱和郵箱 git config user.name 使用者名稱 git config user.email 郵箱 需要修改時 git config global user.name 使用者名稱 git config global user.email 郵箱 查詢 git 本地配...

github配置ssh及多ssh key問題處理

用ssh keygen生成公私鑰。ssh keygen t rsa c 你的郵箱 f ssh id rsa mult在 ssh目錄下會生成一對檔案id rsa mult和id rsa mult.pub檔案 在ssh使用者的配置檔案 ssh config增加github mult.com的配置 在後續...

檢視和生成SSH Key

mac版本 step1 檢視是否已存在 終端輸入 ls al ssh如果提示no such file or directory,則說明沒有,需要新生成 如果出現 id rsa id rsa.pub兩個檔案,說明已經有了,直接通過step4檢視 step2 新生成 終端輸入 ssh keygen t ...