総数:45 今日:1 昨日:1
参考URL SSH接続のための設定まとめ
~$ ls -la .ssh
<filename>が秘密鍵 <filename.pub>が公開鍵
~$ 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]----+ |= (・・省略・・) | | | +-----------------+ ~$
~$ 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]-----+
~$ 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公開鍵 ~$
~$ 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.
ubuntu15.10 desktop をgitサーバとして使用することにしよう
~$ sudo apt-get update ~$ sudo apt-get install virtualbox
以下からダウンロードする。
http://ftp.riken.jp/Linux/ubuntu-releases/wily/ubuntu-15.10-desktop-amd64.iso
手順は省略。
gituser@mother:~$ groups gituser gituser : gituser adm cdrom sudo dip plugdev lpadmin sambashare
gituser@mother:~$ sudo apt-get -y install openssh-server
gituser@mother:~$ mkdir .ssh
あらかじめホスト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:~$
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:~$
gituser@mother:~$ sudo apt-get -y install git-core
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$
$ mkdir -p ~/repositories/my_project/ $ cd ~/repositories/my_project/ $ git init
~/repositories/my_project$ git add.
~/repositories/my_project$ git commit -v
~/repositories/my_project$ git remote add origin gituser@192.168.24.59:/home/gituser/project_000.git
~/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$