SSH Key生成及配置


SSH

  SSH是一種網絡協議,用於計算機之間的加密登錄。

SSH Key生成

個人常用

ssh-keygen -t rsa -f filename -C "your@email.com"

eg: 
ssh-keygen -t rsa -f ~/.ssh/id_rsa.osc -C "awesome@buff.com"

參數說明:-ttype密鑰類型(rsa、dsa...),-f生成文件名,-C備注

SSH Key管理配置

多個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.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM