public_notes/content/20240211185359 Raspi4 Cloudflareでsshアクセスできるようにする.md

43 lines
1.8 KiB
Markdown
Raw Normal View History

2024-02-12 11:20:09 +09:00
# 20240211185359 Raspi4 Cloudflareでsshアクセスできるようにする
#raspi #cloudflare #ssh
## 注意
2024-02-12 18:10:09 +09:00
[[20240211141946 Raspi4 Cloudflareでトンネルを作る|Raspi4 Cloudflareでトンネルを作る]] と同じ。設定方法がどんどん変わる上、私はその専門ではない
2024-02-12 11:20:09 +09:00
## 前提
2024-02-12 20:20:09 +09:00
- [[20240211141946 Raspi4 Cloudflareでトンネルを作る|Raspi4 Cloudflareでトンネルを作る]] の作業が完了している
2024-02-12 20:30:10 +09:00
- [[20240211202623 Raspi4 Cloudflare tunnel経由でhttpsサーバーを公開する|Raspi4 Cloudflare tunnel経由でhttpsサーバーを公開する]] の作業が完了している(ユーザー、サービスなどは作成してある)
2024-02-12 11:20:09 +09:00
2024-02-12 20:20:09 +09:00
## 手順
2024-02-12 20:40:09 +09:00
CNAME recordの追加
2024-02-12 11:20:09 +09:00
```
2024-02-12 20:40:09 +09:00
$ cloudflared tunnel route dns **** pi4.kinoshita-lab.org(ここは好きなやつにする)
2024-02-12T11:33:59Z INF Added CNAME pi4.kinoshita-lab.org which will route to this tunnel tunnelID=****
2024-02-12 11:20:09 +09:00
```
2024-02-12 20:40:09 +09:00
\**** は [[20240212183159 cloudflare トンネルのtoken|cloudflare トンネルのtoken(private)]] を入れる。
systemで動いているcloudflaredにsshの設定を追加。
2024-02-12 11:20:09 +09:00
.ssh/config に、 cloudflaredを使う設定にしたssh設定を追記。
```
Host pi4.kinoshita-lab.org (cloudflareで作ったsshのtunnel)
Port xxxxx (自分が設定したポート番号)
ProxyCommand cloudflared access ssh --hostname %h
```
```
$ ssh pi4.kinoshita-lab.org
```
でログインできればOK。
## cf.
2024-02-12 20:40:09 +09:00
- [Cloudflare Tunnel を使って自宅サーバを公開する - hoge な blog](https://akkyorz.hatenablog.com/entry/2022/12/15/012728)
- [\[Cloudflare\] Cloudflare Tunnel の Ingress rules で複数サービスまとめて公開する - てくなべ (tekunabe)](https://tekunabe.hatenablog.jp/entry/2023/08/05/cloudflare_tunnel_ingress_rules)