総数:45 今日:1 昨日:1
~$ 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]----+ |= (・・省略・・) | | | +-----------------+ ~$
~$ 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> 1679 2月 28 20:59 id_rsa ←★秘密鍵 -rw-r--r-- 1 <username> <username> 397 2月 28 20:59 id_rsa.pub ←★公開鍵 ~$
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$