ubuntu touch へ ssh 接続
1 2 3 4 | Generating public /private rsa key pair. Enter file in which to save the key ( /home/snowpool/ . ssh /id_rsa ): /home/snowpool/ . ssh /id_rsa already exists. Overwrite (y /n )? n |
となるので
ファイル名を指定して鍵を生成することにする
ssh-keygenでファイル名を指定して鍵を生成する
を参考に
-f ファイル名
をつければOK
1 | ssh -keygen -t rsa -f id_rsa_touch |
として
1 2 | Generating public /private rsa key pair. Enter passphrase (empty for no passphrase): |
は
Enter
1 | Enter same passphrase again: |
も
Enter でOK
1 | mv id_rsa_touch* . ssh / |
で
.ssh ディレクトリに移動しておく
次に
Nexus7 で
システム設定 > アプリについて
で
開発者モードをONにする
これで Ubuntu と Nexus 7 を USBで接続し
ubuntu 側から端末で操作していく
1 | adb devices |
を実行し
1 2 3 4 | * daemon not running. starting it now on port 5037 * * daemon started successfully * List of devices attached 09fed9ec unauthorized |
というように認識されればOK
次に
1 | adb shell android-gadget-service enable ssh |
を実行
もし
1 | error: device unauthorized. Please check the confirmation dialog on your device. |
となったら
USBデバッグがONになっていない可能性がある
この場合USBデバッグを許可するか聞かれるダイアログがでてくるので
これを許可し
再度実行すれば成功する
1 | adb shell mkdir /home/phablet/ . ssh |
でディレクトリを作成
1 | adb push ~/. ssh /id_rsa_touch .pub /home/phablet/ . ssh /authorized_keys |
で鍵ファイルを転送
1 2 | adb shell chown -R phablet.phablet /home/phablet/ . ssh adb shell chmod 700 /home/phablet/ . ssh |
で権限と所有者を変更
1 | adb shell ip addr show wlan0| grep inet |
で
IPアドレスを表示
今回の場合は
1 2 | inet 192.168.1.10 /24 brd 192.168.1.255 scope global wlan0 inet6 fe80::da50:e6ff:fe75:4fb3 /64 scope link |
これで接続しようとしたけど
1 | ssh pablet@192.168.1.255 |
としたら
1 | ssh : connect to host 192.168.1.255 port 22: Network is unreachable |
となる
突然「ssh: connect to host ip アドレス port 22: Connection refused」が発生した場合の原因調査と対処法
をみたりしたけど
単純にIPアドレスを間違えていただけだった
1 | ssh pablet@192.168.1.10 |
を実行したが
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now ( man - in -the-middle attack)! It is also possible that a host key has just been changed. The fingerprint for the RSA key sent by the remote host is SHA256:HykJZUEwWspFZp9UbRUWgwSS+wYpJb /IHwXwj6XUVz4 . Please contact your system administrator. Add correct host key in /home/snowpool/ . ssh /known_hosts to get rid of this message. Offending ECDSA key in /home/snowpool/ . ssh /known_hosts :16 remove with: ssh -keygen -f "/home/snowpool/.ssh/known_hosts" -R 192.168.1.10 RSA host key for 192.168.1.10 has changed and you have requested strict checking. Host key verification failed. |
となる
原因を調べると
ssh接続をする際に「WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!」と出てつながらない
にあるように
1 | ssh -keygen -R 192.168.1.10 |
で一度情報を削除
原因は検証のため
virtualbox で仮想マシンを大量に作っていたので
IPが重複していたため
再度
1 | ssh pablet@192.168.1.10 |
を実行すると
1 2 3 4 5 6 7 | The authenticity of host '192.168.1.10 (192.168.1.10)' can't be established. RSA key fingerprint is SHA256:HykJZUEwWspFZp9UbRUWgwSS+wYpJb /IHwXwj6XUVz4 . Are you sure you want to continue connecting ( yes /no )? yes Warning: Permanently added '192.168.1.10' (RSA) to the list of known hosts. Received disconnect from 192.168.1.10 port 22:2: Too many authentication failures Connection to 192.168.1.10 closed by remote host. Connection to 192.168.1.10 closed. |
で弾かれる
Google Nexus5 に Ubuntu Touch をインストールする。(第6版)
を参考に
1 | adb shell chmod 600 /home/phablet/ . ssh /authorized_keys |
でパーミッションを変更したら無事にssh でのログインが可能になった