最简单有效的关于linux下配置Git操作免登录ssh公钥

  1. ssh-keygen -t rsa -b 4096 -C “[email protected]” 然后回车三连击…

  2. 进入目录(执行cd ~/.ssh),可以看到当前目录下多出两个文件 id_rsa.pub 和 id_rsa 带后缀是公钥,不带是私钥

  3. 用vi 编辑器将 id_rsa.pub 打开公钥,将全部内容复制(私钥别动)

    然后进入github 登录>点头像>点settings>点SSH and GPG keys>点New SSH key,如图

  4. Title:只是一个标识,随意写

  5. key:粘贴刚才复制的 内容 ,最后点击 Add SSH key以后本机对远程仓库做操作不用输密码了

备注:ssh-keygen用法我给贴出来了:

ssh-keygen [-q] [-b bits] [-t dsa | ecdsa | ed25519 | rsa]
[-N new_passphrase] [-C comment] [-f output_keyfile]
ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile]
ssh-keygen -i [-m key_format] [-f input_keyfile]
ssh-keygen -e [-m key_format] [-f input_keyfile]
ssh-keygen -y [-f input_keyfile]
ssh-keygen -c [-P passphrase] [-C comment] [-f keyfile]
ssh-keygen -l [-v] [-E fingerprint_hash] [-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 rounds] [-J num_lines]
[-j start_line] [-K checkpt] [-W generator]
ssh-keygen -s ca_key -I certificate_identity [-h] [-U]
[-D pkcs11_provider] [-n principals] [-O option]
[-V validity_interval] [-z serial_number] file ...
ssh-keygen -L [-f input_keyfile]
ssh-keygen -A
ssh-keygen -k -f krl_file [-u] [-s ca_public] [-z version_number]
file ...
ssh-keygen -Q -f krl_file file ...

一般登录机器还是有个自己的钥,还是好一点,具体生成自己的key,其实也很简单:

ssh-keygen -t rsa -b 2048 -f play_key -C play_key

可以不用加密直接三次enter,便生成自己的key

猜你喜欢

转载自www.cnblogs.com/qstudy/p/10010307.html