メンチカツには醤油でしょ!!

AWS/Java/Node.js/Spreadsheets/Docker/Jenkins/コミュニティ・勉強会レポを主とした技術系ブログ

#devsumi 2017参加レポ (Developers Summit 2017) 初日 (2/16)

今年もデブサミへ!

参加4年目です。仕事が忙しいのに申し訳ない。でも参加。

今年のテーマは
"エンジニアとして生きる、技術の先にある現実に踏み出す"
です。papandaさんっぽいです。
やはりデブサミはソウルフルであってほしい。

■ Webフロントエンドの変遷とこれから

前半は歴史の話、侍魂とか懐かしい。

後半はこれからのWebフロントエンドとエンジニアが幸せであり続けるための話。
はじめてのプログレッシブ ウェブアプリ  |  Web  |  Google Developers
GitHub - extensibleweb/manifesto: The Extensible Web Manifesto

Google のインフラ技術から考える理想のDevOps

重要なのは役割ではなく知識範囲としてのフルスタック

製造業などで自工程完結という言葉がありますが、
それぞれのセクションがセクションを越えてやりやすいような仕事をするというのは目指したい所です。セクショナリズムではないですね。

■ 30分でLINE Messaging APIを使ったチャットボットを作って優勝賞金1000万円のLINE Bot Awardsにチャレンジしよう!

最初は概要説明、そして残り13分で
登録〜echobotを動作させるBotのライブコーディング。
IntelliJ使ってたけど結構良さそう…!! 手早い。

■ パネルディスカッション「エンジニアが創るプロダクトの未来 ~エンジニアからプロダクトマネージャーへ~」

自社もプロダクトを持っているので染みる話もあり。
valuable, usable, feasible
この3点で考えるってのは布教していきたい。

f:id:ryoichi0102:20170216205606j:plain

MicrosoftのAI開発機能/サービス

Cognitive Serviceの紹介。

f:id:ryoichi0102:20170216205518j:plain

Azure基礎的な感じですが、私は知らなかったのでミになりました。

■ IoTへのWeb側からの関わりかた

ダイエットフードwとMQTTの紹介。

■ 事業成長にコミットするエンジニア組織への道のり

文化のつくりかたの話。

エンジニア採用に力を入れた後だが、社員エンジニアはこうあるべき、という指針がふわっとしており、その価値が確立できなかった。
組織として見直すことに。そこで、
・売上/利益最大化
・事業成長に負けないように技術的に成長すること
とした。

技術 × 熱意 × プロダクト理解

管理も必要だが、エンジニアが主であることが改めて重要である。

・人事制度の変更:
 マネージャーとエンジニアの乖離についてのキャリアの再定義。
・(開発ではない)合宿:
 模造紙や付箋などでエンジニアのみで実施。課題とアクションプランが明確になるように。
・求職者へのアピール:
 ブログ・インタビュー・OSS活動・社内LT/ハッカソン

■ 視点移動〜ビジネスと組織と人の狭間で越境し続けるエンジニアの物語、その彼岸

私は泣きにきたんでしょうか、感動しました。

speakerdeck.com

久々のpapandaさん。
f:id:ryoichi0102:20170216205505j:plain

www.slideshare.net

わかる・・・本当きてよかった

DockerでFTPサーバーを構築したら簡単すぎた

pullしてrunするだけがいい

色々検討しても良いのかも知れませんが先日のOracle Databaseの件のように動かないコンテナに苦労したり、不可能な環境構築にトライしたくない領域だったので、今回は最初からDocker Hubを検索。Most downloads, most starsを選択しました。
https://hub.docker.com/r/stilliard/pure-ftpd/

なお、SFTPならコチラがMost downloads, most starsでした。
https://hub.docker.com/r/atmoz/sftp/

さて、通常はドキュメント通りに進めますがpure-ftpd:hardened だとアップロード後のリネームができなかったりしたので、pur-ftpd:latestを使います。

> docker pull stilliard/pure-ftpd:latest

latest: Pulling from stilliard/pure-ftpd
386a066cd84a: Pull complete
:::::略:::::: Pull complete
26eb4ca837a0: Pull complete
Digest: sha256:d21f3d12be52d8669b5561c7325f60013b61c9920a78db9d85e2e1545cbdae4f
Status: Downloaded newer image for stilliard/pure-ftpd:latest

> docker run -d --name ftpd_server -p 21:21 -p 30000-30009:30000-30009 -e "PUBLICHOST=localhost" stilliard/pure-ftpd:latest

0206a6e60ff6f738a1e23beecdb46d4631da2e654962dc18e1c7526e325cc840

> docker ps -a

CONTAINER ID  IMAGE                       COMMAND                 CREATED                 STATUS        PORTS                                                     NAMES
0206a6e60ff6  stilliard/pure-ftpd:latest  "/bin/sh -c '/run...."  Less than a second ago  Up 3 seconds  0.0.0.0:21->21/tcp, 0.0.0.0:30000-30009->30000-30009/tcp  ftpd_server

> docker exec -it 0206a6e60ff6 bash

root@0206a6e60ff6:/# cd /home/ftpusers/

root@0206a6e60ff6:/home/ftpusers# ls -la

total 8
drwxr-xr-x 2 root root 4096 Feb 7 20:39 .
drwxr-xr-x 3 root root 4096 Nov 30 08:28 ..

root@0206a6e60ff6:/home/ftpusers# pure-pw useradd my-account-name -f /etc/pure-ftpd/passwd/pureftpd.passwd -m -u ftpuser -d /home/ftpusers/my-account-name

Password: ********
Enter it again: ********

root@0206a6e60ff6:/home/ftpusers# mkdir my-account-name

root@0206a6e60ff6:/home/ftpusers# chown ftpuser:ftpgroup my-account-name

root@0206a6e60ff6:/home/ftpusers# ls -la

total 12
drwxr-xr-x 3 root root 4096 Feb 7 20:41 .
drwxr-xr-x 3 root root 4096 Nov 30 08:28 ..
drwxr-xr-x 3 ftpuser ftpgroup 4096 Feb 7 20:41 my-account-name

/home/ftpuser/【設定したアカウント名】
ディレクトリが作成されていることが確認できます。
ここでFFFTPなどでファイルアップロードなどします。
ユーザー名とパスワードはpure-pwコマンドの時に設定したものです。
(下記の例はtestというディレクトリを作成した例)

root@0206a6e60ff6:/home/ftpusers# cd my-account-name

root@0206a6e60ff6:/home/ftpusers/bob# ls -la

total 12
drwxr-xr-x 3 ftpuser ftpgroup 4096 Feb 7 20:41 .
drwxr-xr-x 3 root root 4096 Feb 7 20:41 ..
drwxr-xr-x 2 ftpuser ftpgroup 4096 Feb 7 20:41 test

簡単すぎて鼻血出そう...

Gitでssh/cloneした時にPermission denied (publickey).

sshは通るけどcloneはできない

あると思います。そんな時のためのメモです。

Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

これですよね。

ssh-keygenでid_rsa以外を指定

ssh-keygenした時にkeyのファイル名を変更していると上記のエラーが出ると思います。(たとえばgithub_id_rsa, github_id_rsa.pub のように)

GitHubのSettings⇒SSHで公開鍵登録しても、
sshは通るけど、cloneはできないという状態になると思います。謎。

この場合は、ssh-addをする必要があります。
デフォルトの名前(id_rsa)であれば生成時にssh-addされるようなのですが
自分でsshキー名を(変更)指定した場合はssh-addされないようです。

一発で決めたい

事前に色々やってた方はまず下記を。

~/.ssh $ vi known_hosts
(known_hostsに登録されていたら面倒なので一旦消しましょう。viの行削除はdd。保存して終了は:wq!です)
~/.ssh $ rm github*
(再度キーを生成しますので一旦うまくいかなかった生成キー消しちゃいましょう)

綺麗になった所で、下記のように一通でいきましょう!

~/.ssh $ ssh-keygen -t rsa -C "my-mailaddress-for-git@mail.com"

Generating public/private rsa key pair.
Enter file in which to save the key (/Users/my-computer-name/.ssh/id_rsa): github_id_rsa
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in github_id_rsa.
Your public key has been saved in github_id_rsa.pub.
The key fingerprint is:
SHA256:abcdefghijklmnopqrstuvwxyzabcdefghijklmnopq my-mailaddress-for-git@mail.com
The key's randomart image is:
+---[RSA 2048]----+
|                 |
|   o             |
|  . *            |
| . * X   .       |
|o * @ @ S        |
|o+.O X +         |
|Eo++* +          |
|.=+=++ +         |
|..oo o+ .        |
+----[SHA256]-----+

(ここでGitHubにてSettings->SSHを開き、生成した鍵の公開鍵の方(github_id_rsa.pubの方)を登録しましょう)


~/.ssh $ ssh -i github_id_rsa git@github.com The authenticity of host 'github.com (192.30.253.113)' can't be established. RSA key fingerprint is SHA256:abcdefghijklmnopqrstuvwxyzabcdefghijklmnopq. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts. PTY allocation request failed on channel 0 Hi ryoichi-obara! You've successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed. ~/.ssh $ ssh-add ~/.ssh/github_id_rsa Identity added: /Users/my-computer-name/.ssh/github_id_rsa (/Users/my-computer-name/.ssh/github_id_rsa)

これでも
Could not open a connection to your authentication agent.
などとエラーが出る場合はssh-addする前にこのようにしましょう。

~/.ssh $ eval "$(ssh-agent)"

Agent pid 59566

~/.ssh $ ssh-add ~/.ssh/github_id_rsa

Enter passphrase for ~/.ssh/github_id_rsa: 

$ git clone git@github.com:ryoichi-obara/test.git

(成功)

ssh-addが消えて立ち上げるたびに毎回やらないといけない問題

Windows環境(git bash)のみですかね。
.bashrcに書いてgit bash起動時に実行されるようにしておけば良さそうです、、と以前まで書いていたのですがssh config (~/.ssh/config) に書けば良さそうです。
ssh configは、sshの接続設定をまとめて定義できるファイルです。

一般的にHost名はただの設定名ですが、ここでgithub.comと設定しないと繋がらないです。これにずっと悩まされてましたが解決!

Host github.com
HostName github.com
User git
Port 22
IdentityFile ~/.ssh/github_id_rsa

この設定は

$ ssh git@github.com -p 22 -i ~/.ssh/github_id_rsa

と等価です。設定名に github と指定しているので、

$ ssh github

で繋がるようになります。

--- ↓ 旧(一応) .bashrcに書くやり方 ---
$ vi ~/.bashrc
eval `ssh-agent`
ssh-add ~/.ssh/github_id_rsa

なお、立ち上げたときに
WARNING: Found ~/.bashrc but no ~/.bash_profile, ~/.bash_login or ~/.profile.
が出て気になる場合は

$ touch ~/bash_profile

などとして空の.bash_profileを作っておけば警告は出なくなります。

参考

Mac ssh-add 自動 - @//メモ
https://hondou.homedns.org/pukiwiki/index.php?Mac%20ssh-add%20%BC%AB%C6%B0

GitHubSSHに関してのドキュメント
Error: Permission denied (publickey) - User Documentation

d.hatena.ne.jp

fa11enprince.hatenablog.com

過去にこんな記事も書いてました

ryoichi0102.hatenablog.com

ryoichi0102.hatenablog.com