#author("2026-06-02T15:14:46+09:00","","") #author("2026-06-02T15:23:32+09:00","","") #nofollow #norelated 総数:&counter(total); 今日:&counter(today); 昨日:&counter(yesterday); * もくじ [#n63316e8] #contents ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKOOlj3MsI8ldFZra9cYZP8Bh98M9K895uwMIfY71O/H ryu@FMVN90E2GG&br; 参考URL [[SSH接続のための設定まとめ>https://qiita.com/010Ri/items/0a09356633655b5613ee]] * sshの準備 client側 [#lcd196a7] ** 公開鍵が既に作成されているかどうか確認する [#ld7b02d9] ***ある場合は、公開鍵は ~/.ssh というディレクトリにあるはず。 [#i24668d4] ~$ ls -la .ssh -ある場合は、<filename>と<filename.pub>というペアのファイルたちがある。 <filename>が秘密鍵 <filename.pub>が公開鍵 ** 公開鍵がまだ無い場合は作成する [#d5d5d734] ***ssh-keygenコマンドで作成する。 [#qe64c324] -公開鍵の種類 RSA (ssh-rsa) ~$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/<username>/.ssh/id_rsa):←★このままenterキーを押す Created directory '/home/<username>/.ssh'. Enter passphrase (empty for no passphrase): ←★このままenterキーを押す Enter same passphrase again: ←★このままenterキーを押す Your identification has been saved in /home/<username>/.ssh/id_rsa. Your public key has been saved in /home/<username>/.ssh/id_rsa.pub. The key fingerprint is: b6:(・・・省略・・・):07 <username>@<hostname> The key's randomart image is: +--[ RSA 2048]----+ |= (・・省略・・) | | | +-----------------+ ~$ -公開鍵の種類 ED25519 (ssh-ed25519) ~$ ssh-keygen -t ed25519 -C "your_email@example.com" Generating public/private ed25519 key pair. Enter file in which to save the key (/home/<username>/.ssh/id_ed25519): ←★このままenterキーを押す Enter passphrase for "/home/<username>/.ssh/id_ed25519" (empty for no passphrase): Enter same passphrase again: ←★このままenterキーを押す Your identification has been saved in /home/<username>/.ssh/id_ed25519 Your public key has been saved in /home/<username>/.ssh/id_ed25519.pub The key fingerprint is: SHA256:mPuwpXVcU+B7peHkemLe3U88cbLMNuigMLI2uAOWpTI your_email@example.com The key's randomart image is: +--[ED25519 256]--+ | (・・省略・・) | +----[SHA256]-----+ ***作成された鍵ファイルを確認する。 [#ic056503] ~$ ls -la .ssh 合計 16 drwx------ 2 <username> <username> 4096 2月 28 20:59 . drwxr-xr-x 47 <username> <username> 4096 2月 28 20:58 .. -rw------- 1 <username> <username> 411 9月 19 2025 id_ed25519 ←★ED25519秘密鍵 -rw-r--r-- 1 <username> <username> 100 9月 19 2025 id_ed25519.pub ←★ED25519公開鍵 -rw------- 1 <username> <username> 1679 2月 28 20:59 id_rsa ←★RSA秘密鍵 -rw-r--r-- 1 <username> <username> 397 2月 28 20:59 id_rsa.pub ←★RSA公開鍵 ~$ ** 自分(client)の公開鍵を Git サーバーへ自分で登録する [#tf0c9c9a] *** ssh-copy-idコマンドを使用する。 [#m7c67534] ~$ ssh-copy-id -i .ssh/id_ed25519.pub <username>@<server ip address> /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: ".ssh/id_ed25519.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys <username>@<server ip address>'s password: ←★サーバーへのログイン時のパスワードを入力する。 Number of key(s) added: 1 Now try logging into the machine, with: "ssh '<username>@<server ip address>'" and check to make sure that only the key(s) you wanted were added. -できない場合は下記。 ** 自分(client)の公開鍵を Git サーバーの管理者に連絡する。 [#t7886bbc] ***id_rsa.pubの内容をメールなどでGit サーバーの管理者に連絡する。 [#nedc8f4d] * sshの準備 sever側 [#e4a1897b] ubuntu15.10 desktop をgitサーバとして使用することにしよう **ubuntu15.10 desktop を virtual box で仮想マシン上にインストールする。 [#qc4ac5b7] ***virtual box のインストール [#c3ce4383] ~$ sudo apt-get update ~$ sudo apt-get install virtualbox ***ubuntu-15.10-desktop のダウンロード [#peede671] 以下からダウンロードする。&br; http://ftp.riken.jp/Linux/ubuntu-releases/wily/ubuntu-15.10-desktop-amd64.iso ***ubuntu15.10 desktop を virtual box で仮想マシン上にインストールする。 [#nc2986d6] 手順は省略。 **gituserというユーザを作成しておく [#lc58bec4] **gituserが所属するグループを確認する。 [#s2b7cafe] gituser@mother:~$ groups gituser gituser : gituser adm cdrom sudo dip plugdev lpadmin sambashare **openssh-serverをインストールしておく。 [#kd382732] gituser@mother:~$ sudo apt-get -y install openssh-server **.ssh ディレクトリを作成しておく。 [#m7026e33] gituser@mother:~$ mkdir .ssh **gitクライアントたちの SSH 公開鍵をそのユーザーの authorized_keys に追加していく [#e8a8d4e3] あらかじめホストOSとの共有ディレクトリ /media/sf_share_with_host/ に 公開鍵ファイル を置いておくとする。 gituser@mother:~$ sudo su [sudo] password for gituser: root@mother:/home/gituser# ls -la /media/sf_share_with_host/ 合計 12 drwxrwx--- 1 root vboxsf 4096 2月 28 22:11 . drwxr-xr-x 4 root root 4096 2月 28 22:10 .. root@mother:/home/gituser# cp -p /media/sf_share_with_host/id_rsa.pub Downloads/ root@mother:/home/gituser# exit exit gituser@mother:~$ ls -la Downloads/ gituser@mother:~$ ls -la Downloads/ 合計 12 drwxr-xr-x 2 gituser gituser 4096 2月 28 22:15 . drwxr-xr-x 20 gituser gituser 4096 2月 28 22:10 .. -rwxrwx--- 1 root vboxsf 397 2月 28 20:59 id_rsa.pub gituser@mother:~$ sudo chown gituser:gituser Downloads/id_rsa.pub gituser@mother:~$ ls -la Downloads/ 合計 12 drwxr-xr-x 2 gituser gituser 4096 2月 28 22:15 . drwxr-xr-x 20 gituser gituser 4096 2月 28 22:10 .. -rwxrwx--- 1 gituser gituser 397 2月 28 20:59 id_rsa.pub gituser@mother:~$ ***これを authorized_keys に追加していく。 [#kc3b0a38] gituser@mother:~$ cat Downloads/id_rsa.pub >> ~/.ssh/authorized_keys gituser@mother:~$ ls -la .ssh/ 合計 12 drwxrwxr-x 2 gituser gituser 4096 2月 28 22:27 . drwxr-xr-x 20 gituser gituser 4096 2月 28 22:10 .. -rw-rw-r-- 1 gituser gituser 397 2月 28 22:27 authorized_keys gituser@mother:~$ **gitをインストールする。 [#ra15d850] gituser@mother:~$ sudo apt-get -y install git-core **gitクライアントが使うための空のリポジトリを作成する。 [#jab4c93d] gituser@mother:~$ mkdir project_000.git gituser@mother:~$ cd project_000.git/ gituser@mother:~/project_000.git$ git --bare init --shared Initialized empty shared Git repository in /home/gituser/project_000.git/ gituser@mother:~/project_000.git$ *gitクライアント側 [#cea30ed8] **git initでリポジトリ作成する [#h7c9d11a] $ mkdir -p ~/repositories/my_project/ $ cd ~/repositories/my_project/ $ git init **index.htmlを作成する。 [#l54af100] **git add. [#g33ae5b9] ~/repositories/my_project$ git add. **git commit [#ac29063e] ~/repositories/my_project$ git commit -v **git remote add origin gituser@192.168.24.59:/home/gituser/project_000.git [#b704c226] ~/repositories/my_project$ git remote add origin gituser@192.168.24.59:/home/gituser/project_000.git **git push origin master [#ca3917af] ~/repositories/my_project$ git push origin master Counting objects: 3, done. Delta compression using up to 4 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 268 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To gituser@192.168.24.59:/home/gituser/project_000.git * [new branch] master -> master ~/repositories/my_project$