Skip to content

Commit 123fe61

Browse files
authored
Create lock-down-sshd.md
1 parent 14a2cdf commit 123fe61

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tailscale/lock-down-sshd.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Restricting SSH connections to devices within a Tailscale network
2+
3+
I'm running an AWS Lightsail instance and I want to only be able to SSH to it from devices connected to my [Tailscale](https://tailscale.com/) network.
4+
5+
I installed Tailscale on the instance using their [Ubuntu installation instructions](https://tailscale.com/kb/1037/install-ubuntu-1804). I have it running on my laptop and phone as well.
6+
7+
I ran `ifconfig tailscale0` to find the Tailscale IP for instance:
8+
```
9+
$ ifconfig tailscale0
10+
tailscale0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1420
11+
inet 100.122.168.55 netmask 255.192.0.0 destination 100.122.168.55
12+
inet6 fe80::33a:342a:2733:186a prefixlen 64 scopeid 0x20<link>
13+
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 500 (UNSPEC)
14+
RX packets 2147 bytes 95030 (95.0 KB)
15+
RX errors 0 dropped 0 overruns 0 frame 0
16+
TX packets 990 bytes 66448 (66.4 KB)
17+
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
18+
```
19+
Then I ran `sudo vi /etc/ssh/sshd_config` and added that address as the only `ListenAddress`:
20+
```
21+
#Port 22
22+
#AddressFamily any
23+
#ListenAddress 0.0.0.0
24+
#ListenAddress ::
25+
ListenAddress 100.122.168.55
26+
```
27+
Then restarted SSH:
28+
```
29+
sudo service ssh restart
30+
```
31+
I can now SSH to Tailscale from my laptop, but only if I use the Tailscale IP address for the server (I thought it was broken at first because I was still SSHing to the internet public IP):
32+
```
33+
ssh [email protected] -i lightsail.pem
34+
```
35+
Handy debugging tip: `tail -f /var/log/auth.log` shows recent sign-in attempts.
36+
37+
Thanks to [@apenwarr for tips](https://twitter.com/apenwarr/status/1253318250131263489).

0 commit comments

Comments
 (0)