Windowsのssh-agentの設定、eval `ssh-agent`、evalを使う

WindowsGithub Desktopをアップデートしたら、Authentication failedした。

>Authentication failed. You may not have permission to access the repository or the repository may have been archived. Open options and verify that you're signed in with an account that has permission to access this repository.

f:id:takuwz:20181220230544j:plain

 

sshキーの追加をしていないので、windowsでも追加してみる。

 

参考:

 

Generating a new SSH key and adding it to the ssh-agent - User Documentation

ssh-addできなかったときへの対処 - Qiita

ssh-agentを利用して、安全にSSH認証を行う - Qiita

 

コマンドプロンプトで失敗。

C:\Users\rize>ssh-add
Error connecting to agent: No such file or directory

f:id:takuwz:20181220231008j:plain

 

git bashをインストールしてたことを思い出し、設定した。

.sshフォルダに秘密鍵をコピーした。

windowsではevalが必要っぽい。

 

$ eval `ssh-agent`

$ ssh-add ./id_rsa_github

 

rize@tedeza MINGW64 ~
$ cd .ssh

rize@tedeza MINGW64 ~/.ssh
$ ls
id_rsa_github id_rsa_github.pub

rize@tedeza MINGW64 ~/.ssh
$ ssh-add
Could not open a connection to your authentication agent.

rize@tedeza MINGW64 ~/.ssh
$ ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-dCFZfDNQzjwV/agent.2284; export SSH_AUTH_SOCK;
SSH_AGENT_PID=8688; export SSH_AGENT_PID;
echo Agent pid 8688;

rize@tedeza MINGW64 ~/.ssh
$ eval `ssh-agent`
Agent pid 13172

rize@tedeza MINGW64 ~/.ssh
$ ssh-add -K ./id_rsa_github
ssh-add: unknown option -- K
usage: ssh-add [options] [file ...]
Options:
-l List fingerprints of all identities.
-E hash Specify hash algorithm used for fingerprints.
-L List public key parameters of all identities.
-k Load only keys and not certificates.
-c Require confirmation to sign using identities
-m minleft Maxsign is only changed if less than minleft are left (for XMSS)
-M maxsign Maximum number of signatures allowed (for XMSS)
-t life Set lifetime (in seconds) when adding identities.
-d Delete identity.
-D Delete all identities.
-x Lock agent.
-X Unlock agent.
-s pkcs11 Add keys from PKCS#11 provider.
-e pkcs11 Remove keys provided by PKCS#11 provider.
-q Be quiet after a successful operation.

rize@tedeza MINGW64 ~/.ssh
$ ssh-add ./id_rsa_github
Enter passphrase for ./id_rsa_github:
Identity added: ./id_rsa_github (./id_rsa_github)

rize@tedeza MINGW64 ~/.ssh
$ vi config

rize@tedeza MINGW64 ~/.ssh
$ ssh -T github
The authenticity of host 'github.com (192.30.255.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.255.113' (RSA) to the list of known hosts.
Hi takurx! You've successfully authenticated, but GitHub does not provide shell access.

rize@tedeza MINGW64 ~/.ssh
$ ssh-add -l
4096 SHA256:n9C61lvsttfYTxPa/psGn9y/Ek2RgTQ0xofRbWj6j/g ./id_rsa_github (RSA)

f:id:takuwz:20181220232127j:plain

 

それとGithub Desktopの

File>OptionsのAdvancedタブに

shell : Git Bash

に設定した。

f:id:takuwz:20181220232225j:plain