LoginSignup
0

More than 5 years have passed since last update.

mercurial で SSH 鍵を指定して作業する

Last updated at Posted at 2014-07-13

鍵が複数ある場合、~/.ssh/config を編集すれば良いのだけど、諸事情で編集できない場合は以下の方法で作業できる。

http 経由で clone して、リポジトリの .hg/hgrc を編集する。

ドメイン名などは自分のに合わせる。

hg clone http://example.com/hg/hoge hoge
vim hoge/.hg/hgrc
[ui]
ssh = /usr/bin/ssh -i ~/.ssh/id_rsa-hoge -p ポート番号
[paths]
default = ssh://myuser@example.com/hg/hoge

-p ポート番号はデフォルトの 22 番を使っているなら必要なし。
default の値は http://... を ssh://ユーザ名@... に変えるだけ。

--ssh オプションを使う

一時的であれば、コマンドに以下のオプションを追加すれば良い。

--ssh "ssh -i ~/.ssh/id_rsa-hoge -p <port>" 

組み合わせる

hg clone --ssh "/usr/bin/ssh -i ~/.ssh/id_rsa-hoge" ssh://myuser@example.com/hg/hoge hoge
vim hoge/.hg/hgrc

以下を追加する
[ui]
ssh = /usr/bin/ssh -i ~/.ssh/id_rsa-hoge

リポジトリごとに鍵を管理するなら、多分これが一番楽。

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
0