7
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

世界の果てからssh、固定ドメインで自宅ラズパイへ簡単接続

Posted at

はじめに

どこからでも固定ドメインで自宅ラズパイへssh接続できるよう、Serveoを使った設定例を紹介します。
serveo.netのサブ・ドメインを利用します。仮にドメイン名をtest1234.serveo.netとします。
無料で利用できます。ルータの設定変更は必要ありません。

参考:

サーバ側(ラズパイ)の設定

:one:一度sshを起動し、serveo.netをknown hostsとして登録します。

pi@raspberrypi:~ $ /usr/bin/ssh -R test1234:22:localhost:22 serveo.net
The authenticity of host 'serveo.net (159.89.214.31)' can't be established.
RSA key fingerprint is SHA256:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'serveo.net,159.89.214.31' (RSA) to the list of known hosts.
Forwarding SSH traffic from alias "test1234"
Press g to start a GUI session and ctrl-c to quit.

[ctrl]+[c]で中断します。

:two:プロセス管理・デーモン化ツールsupervisorを使い、Serveoをデーモン化します。

pi@raspberrypi:~ $ sudo apt-get update
pi@raspberrypi:~ $ sudo apt-get install supervisor
pi@raspberrypi:~ $ sudo vi /etc/supervisor/conf.d/serveo.conf
/etc/supervisor/conf.d/serveo.conf
[program:serveo]
command=/usr/bin/ssh -o ServerAliveInterval=60 -R test1234:22:localhost:22 serveo.net
numprocs=1
autostart=true
user=pi
pi@raspberrypi:~ $ sudo service supervisor start
pi@raspberrypi:~ $ sudo reboot

クライアント側(Android/Termux)から接続します。

$ ssh -J serveo.net pi@test1234
Hi there
The authenticity of host 'test1234 (<no hostip for proxy command>)' can't be established.
ECDSA key fingerprint is SHA256:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'tst1234' (ECDSA) to the list of known hosts.
pi@test1234' password:
pi@raspberrypi:~ $ 

おわりに

サーバ側もクライアント側も、sshが使えれば簡単に利用できて便利ですよ。(=^・^=)

7
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?