页面“Django google authenticator”与“多个git账号之间的切换 多个git账号指定不同的key”之间的差异

来自linux中国网wiki
(页面间的差异)
跳到导航 跳到搜索
(导入1个版本)
 
docker>Evan
(导入1个版本)
 
第1行: 第1行:
=google-authenticator client=
 
  
==安装==
+
多个git账号之间的切换 多个git账号指定不同的key
  
这个不用说啦  play 商店中 找 google 身份验证器.我的手机是android 7
+
ssh可以通过-i使用指定的私钥文件,如:
  
 +
ssh -i ~/mykey_rsa username@host
  
== config==
+
但是走ssh协议的git却没有类似的参数可以指定,只能是使用用户默认的ssh私钥。
添加 ==> 输入提供的密钥  记得要保存好你的密钥哦
 
  
 +
而git 一般也是用key认证的,如果你来我一样的情形 ,怎么办 ? 先假设我有两个账号,一个是github上的,一个是公司gitlab上面的。先为不同的账号生成不同的ssh-key
  
=google-authenticator server=
+
ssh-keygen  -t rsa -f ~/.ssh/id_rsa_work -C [email protected]
  
=设想=
+
然后根据提示连续回车即可在~/.ssh目录下得到id_rsa_work和id_rsa_work.pub两个文件,id_rsa_work.pub文件里存放的就是我们要使用的key
可以加个不回显示的验证码,哈哈 笑死
 
  
=参考=
+
ssh-keygen -t rsa -f ~/.ssh/id_rsa_github -C [email protected]
  
[http://jungor.me/?p=547  最好的可以直接代码之Django + Google Authenticator]
+
然后根据提示连续回车即可在~/.ssh目录下得到id_rsa_github和id_rsa_github.pub两个文件,id_rsa_gthub.pub文件里存放的就是我们要使用的key
  
[https://medium.com/@jainsahil1997/simple-google-authentication-in-django-58101a34736b Simple Google Authentication in Django]
+
编辑 ~/.ssh/config,设定不同的git 服务器对应不同的key
  
[https://zh.wikipedia.org/wiki/Google%E8%BA%AB%E4%BB%BD%E9%AA%8C%E8%AF%81%E5%99%A8 Google身份验证器]
+
在本机添加
 +
<pre>cat ~/.ssh/config
  
https://pypi.python.org/pypi/django-google-authenticator
+
Host github.com
 +
  hostname github.com
 +
  User git
 +
  #port 22
 +
  IdentityFile /home/evan/.ssh/id_rsa_github
 +
  IdentitiesOnly yes
 +
 
 +
</pre>
  
https://github.com/Bouke/django-two-factor-auth
+
#建一个gitlab别名,新建的帐号使用这个别名做克隆和更新
 +
<pre>Host 192.168.11.11
 +
  HostName 192.168.11.11
 +
  User work
 +
  IdentityFile ~/.ssh/id_rsa_work
  
 +
</pre>
  
 +
打开 [https://github.com/settings/ssh https://github.com/settings/ssh] 把pub key (id_rsa_github.pub) 添加一下
  
https://github.com/gnosis/django-google-authenticator
+
ssh -vT git@github.com
  
 +
看到 You’ve successfully 就表示OK了
  
 +
多个git账号之间的切换 也可以多个github 帐号 [http://memoryboxes.github.io/blog/2014/12/07/duo-ge-gitzhang-hao-zhi-jian-de-qie-huan/ http://memoryboxes.github.io/blog/2014/12/07/duo-ge-gitzhang-hao-zhi-jian-de-qie-huan/]
  
 +
命令行下的git配置问题: 多个sshkey, 多个用户身份, git alias [http://www.liaohuqiu.net/cn/posts/git-setup-and-setting/ http://www.liaohuqiu.net/cn/posts/git-setup-and-setting/]
  
[https://www.jianshu.com/p/6c751ddbbc7c 谷歌身份验证使用教程及失效详解]
+
Git Config 命令查看配置文件 [https://cnbin.github.io/blog/2015/06/19/git-config-ming-ling-cha-kan-pei-zhi-wen-jian/ https://cnbin.github.io/blog/2015/06/19/git-config-ming-ling-cha-kan-pei-zhi-wen-jian/]
  
[https://help.aliyun.com/document_detail/28669.html 安卓版Google Authenticator安装及使用指导]
+
ssh-keygen -t rsa -f ~/.ssh/id_rsa_evan -C evan886@gmail.com
  
[https://gadgets.ndtv.com/apps/features/google-authenticator-app-gmail-account-two-factor-security-1684339 How to Use Google Authenticator App to Secure Your Gmail Account ]
+
[https://www.linuxchina.net/?p=3393 https://www.linuxchina.net/?p=3393]
[https://www.jianshu.com/p/5806ff9c0cc5 在Django中定制身份验证]
 
  
[https://support.google.com/accounts/troubleshooter/4430955?hl=zh-Hans#ts=4430956 google使用新手机接收两步验证码]
+
&nbsp;
  
[https://www.google.com/landing/2step/#tab=how-it-works 增强 Google 帐户的安全性]
+
&nbsp;
  
[https://www.howtoing.com/secure-ssh-with-google-authenticator-on-centos-7 CentOS 7上使用Google Authenticator双重身份验证保护SSH安全]
+
[[Category:git]]
 
 
[https://www.freehao123.com/two-factor-authentication/ WordPress和VPS利用Google Authenticator两步验证]
 
 
 
[https://django-two-factor-auth.readthedocs.io/en/stable/index.html Django Two-Factor Authentication Documentation]
 
 
 
[https://teakki.com/p/5929371e6e5c97852743d7e7 在Django中自定义身份验证]
 
 
 
 
 
 
 
 
 
== github上的GoogleAuthenticator ==
 
 
 
https://github.com/collective/collective.googleauthenticator
 
 
 
https://github.com/shinsaka/googleauthenticator_demo
 
 
 
https://github.com/cqf539/GoogleAuthenticator
 
 
 
https://github.com/gnosis/django-google-authenticator
 
 
 
==google 验证 ==
 
 
 
[http://www.williamlong.info/archives/2754.html Google两步验证安装使用方法]
 
 
 
[https://www.zhihu.com/question/20462696 谷歌验证 (Google Authenticator) 的实现原理]
 
 
 
[[category:django]]
 

2017年1月23日 (一) 09:56的版本

多个git账号之间的切换 多个git账号指定不同的key

ssh可以通过-i使用指定的私钥文件,如:

ssh -i ~/mykey_rsa username@host

但是走ssh协议的git却没有类似的参数可以指定,只能是使用用户默认的ssh私钥。

而git 一般也是用key认证的,如果你来我一样的情形 ,怎么办 ? 先假设我有两个账号,一个是github上的,一个是公司gitlab上面的。先为不同的账号生成不同的ssh-key

ssh-keygen  -t rsa -f ~/.ssh/id_rsa_work -C [email protected]

然后根据提示连续回车即可在~/.ssh目录下得到id_rsa_work和id_rsa_work.pub两个文件,id_rsa_work.pub文件里存放的就是我们要使用的key

ssh-keygen -t rsa -f ~/.ssh/id_rsa_github -C [email protected]

然后根据提示连续回车即可在~/.ssh目录下得到id_rsa_github和id_rsa_github.pub两个文件,id_rsa_gthub.pub文件里存放的就是我们要使用的key

编辑 ~/.ssh/config,设定不同的git 服务器对应不同的key

在本机添加

cat ~/.ssh/config

Host github.com
  hostname github.com
  User git
  #port 22
  IdentityFile /home/evan/.ssh/id_rsa_github
  IdentitiesOnly yes
  
  1. 建一个gitlab别名,新建的帐号使用这个别名做克隆和更新
Host 192.168.11.11
  HostName 192.168.11.11
  User work
  IdentityFile ~/.ssh/id_rsa_work

打开 https://github.com/settings/ssh 把pub key (id_rsa_github.pub) 添加一下

ssh -vT [email protected]

看到 You’ve successfully 就表示OK了

多个git账号之间的切换 也可以多个github 帐号 http://memoryboxes.github.io/blog/2014/12/07/duo-ge-gitzhang-hao-zhi-jian-de-qie-huan/

命令行下的git配置问题: 多个sshkey, 多个用户身份, git alias http://www.liaohuqiu.net/cn/posts/git-setup-and-setting/

Git Config 命令查看配置文件 https://cnbin.github.io/blog/2015/06/19/git-config-ming-ling-cha-kan-pei-zhi-wen-jian/

ssh-keygen -t rsa -f ~/.ssh/id_rsa_evan -C [email protected]

https://www.linuxchina.net/?p=3393