LoginSignup
4
5

More than 5 years have passed since last update.

とりあえずsshを使いたくてググりながらなんとかなった時のメモ

Last updated at Posted at 2017-06-20

何もよくわからない状態でとりあえずbitbucketでsshを使いたくてググりながらなんとかなった時のメモ

試行錯誤

SSH入ってますかー?

$ ssh -V 
OpenSSH_7.3p1, LibreSSL 2.4.1

/.sshの中何が入ってんのよー?

$ ls -a ~/.ssh
known_hosts  id_dsa

ssh鍵をジェネレートするよー

$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/hogenobu/.ssh/id_rsa):                          
/Users/hogenobu/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/hogenobu/.ssh/id_rsa.
Your public key has been saved in /Users/hogenobu/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:M2AfimvEeUB2Mgc0IhmVxZ+iTitp5/+cM/oIWiBHD5U hogenobu@PC
The key's randomart image is:
+---[RSA 2048]----+
|o+o=@oo          |
|...=E*           |
|  o ..o..        |
| . +.=o+ .       |
|....*.o S        |
|..+. o   o       |
| + +o            |
|o.=o. oo.        |
|.oo..++=o        |
+----[SHA256]-----+

※実は/.sshにすでにkyeがあるのに上うっかりOverwriteにyesと答えてあとで結構苦労した話もあるけど割愛

$ ps -e | grep [s]sh-agent
 2578 ??         0:00.02 /usr/bin/ssh-agent -l
$ ssh-agent /bin/bash
$ ssh-add ~/.ssh/id_rsa
$ ssh-add -l 
$ cat ~/.ssh/id_rsa.pub
ssh-rsa ごにゃごにゃ
$ pbcopy < ~/.ssh/id_rsa.pub
$ cd ~/.ssh
$ touch config
$ chmod 700 config
$ vi config

vim弱だから参考になりました (http://qiita.com/hide/items/5bfe5b322872c61a6896)

Host bitbucket.org
  HostName bitbucket.org
  IdentityFile ~/.ssh/bitbucket/id_rsa
  User hogenobu
  Port 22
  TCPKeepAlive yes
  IdentitiesOnly yes
$ ssh -T bitbucket.org
no such identity: /Users/hogenobu/.ssh/bitbucket/id_rsa: No such file or directory
Permission denied (publickey).

ダメだった

公式 https://ja.confluence.atlassian.com/bbkb/permission-denied-publickey-302811860.html

$ ssh -T hg@bitbucket.org
logged in

ログインできた

参考になったサイト様たち

公式
https://confluence.atlassian.com/bitbucket/set-up-ssh-for-git-728138079.html

[Bitbucket]gitコマンドでBitbucketを操作する 〜基本編〜
http://qiita.com/yyosuke/items/986dabc9906674e2ea97

bitbucketにgitでpushするとPermission denied (publickey).と表示されるときの解決法
 http://kuroneko0208.hatenablog.com/entry/2013/08/22/181251

Gitで”Permission denied (publickey).” が出たときのメモ
http://qiita.com/sygnas/items/43306a738f01cb7ab45c

初めてGitHubリポジトリにpushしたらrejectedエラーになったときの対応メモ http://qiita.com/takanatsu/items/fc89de9bd11148da1438

ペア鍵について

gitlabへのpush時に「does not appear to be a git repository」と表示されるときの対策
http://qiita.com/volanja/items/d0ed86dbb6e4ec7d7a54

BitbucketにSSHでアクセスする(複数アカウントもおっけー)
http://cflat-inc.hatenablog.com/entry/20130311/1362955659

GitHubやBitbucketで複数アカウントを使い分ける方法
http://blog.amanesiku.com/?p=390

4
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5