1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

gitサーバを構築して開発するときのssh接続について

Last updated at Posted at 2021-12-15

gitサーバを家に建てたくなったのでついでにsshで公開鍵認証onlyでアクセスするようにしてみたときの雑記
(単純にあとからやり直そうとした際に忘れそうなので書きます)

構築の流れ

  • サーバ側にgitをインストール
  • adduser git(正直個人的にはrootでもいいと思ってる) && su git
  • サーバの容量の大きいディスクをマウント,gitユーザのhome配下の適当な場所にバインド
  • バインドしたフォルダの任意の場所でgit init --bare --share=true
  • groupadd {グループ名} で任意のグループを作成(これがリポジトリ開発者のグループ)
  • gpasswd -a {ユーザ名} {グループ名}でグループにリポジトリ開発者を追加
  • リポジトリの所有権限を作成したグループにしておく
  • 公開鍵をサーバに登録
    • ssh-copy-id -i ~/.ssh/id_rsa.pub [リモートユーザー]@[リモートサーバーのホスト名] ←linux to linuxならこれが早い
    • windowsの場合は物理で頑張るなり,一時的にsshへのパスワード認証許可だったりで公開鍵を渡す
  • クライアント側でも.ssh/configを作成してアクセスを簡単にする
host ${hostname}
user ${remote user id}
hostname ${server ip or domain}
port ${sshのポートを変えてなければ22}
IdentityFile ${秘密鍵へのパス}

configを作成しておくとsshでgit cloneする際にgit clone ssh://hostname/サーバのリポジトリまでのパス
で済むので便利

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?