0
0

git,ssh設定各種

Posted at

■ ssh公開鍵作成
生成コマンド実行

ssh-keygen

以下入力求められる

Generating public/private rsa key pair.
Enter file in which to save the key (/Users/ユーザー名/.ssh/id_rsa): <--鍵の保存先 
Enter passphrase (empty for no passphrase):  <-- パスフレーズを入力(任意)
Enter same passphrase again:  <-- もう一度、パスフレーズを入力(任意)
Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.

秘密鍵の確認

ls -l ~/.ssh/id_rsa

公開鍵の確認

ls -l ~/.ssh/id_rsa.pub

権限の設定

chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub

設定ファイルの設定

~/.ssh/config
Host <ホスト名>
  User <リモート側ユーザ>
  IdentityFile ~/.ssh/id_rsa #ssh-keygenでファイル名変えたらここも変更

疎通 確認

ssh -T <ユーザ名>@<ホスト名>

うまくいかない時のデバッグ

ssh -vT <ユーザ名>@<ホスト名>

■ gitサーバー側の公開鍵設定に以下から取得できるテキストはりつけ
(サーバー側いろいろあるので割愛)

cat ~/.ssh/id_rsa.pub

■ 以下のような形で取得
git clone -b main ./src

以下パーミッション設定しないと動かない時あったのでメモ
パーミッションの設定:

sudo chmod 644 /etc/crypto-policies/back-ends/openssh.config

所有者の設定:

sudo chown root:root /etc/crypto-policies/back-ends/openssh.config

ファイルの確認:

ls -l /etc/crypto-policies/back-ends/openssh.config

出力が以下を確認

-rw-r--r-- 1 root root <file_size> <date> /etc/crypto-policies/back-ends/openssh.config

SSHサービスの再起動:

sudo systemctl restart sshd
0
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
0
0