add ssh_over_jump
parent
dff2c293f4
commit
c75c0b9623
|
@ -0,0 +1,58 @@
|
||||||
|
<mxfile host="65bd71144e">
|
||||||
|
<diagram id="l0u-TbN7LvwXP4Vuh3t5" name="Page-1">
|
||||||
|
<mxGraphModel dx="1041" dy="817" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" background="#ffffff" math="0" shadow="0">
|
||||||
|
<root>
|
||||||
|
<mxCell id="0"/>
|
||||||
|
<mxCell id="1" parent="0"/>
|
||||||
|
<mxCell id="14" value="" style="rounded=1;whiteSpace=wrap;html=1;fontColor=#1b0490;fillColor=#D9FFDD;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="395" y="165" width="335" height="205" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="13" value="" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#CCFFE6;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="60" y="225" width="190" height="165" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="8" style="edgeStyle=none;html=1;exitX=0.31;exitY=0.8;exitDx=0;exitDy=0;exitPerimeter=0;entryX=1;entryY=0.7;entryDx=0;entryDy=0;entryPerimeter=0;endArrow=none;endFill=0;strokeColor=#000000;" edge="1" parent="1" source="2" target="3">
|
||||||
|
<mxGeometry relative="1" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="10" style="html=1;exitX=0.875;exitY=0.5;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;entryPerimeter=0;endArrow=none;endFill=0;strokeColor=#000000;" edge="1" parent="1" source="2" target="5">
|
||||||
|
<mxGeometry relative="1" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="2" value="<font color="#1b0490">Интернет</font>" style="ellipse;shape=cloud;whiteSpace=wrap;html=1;fillColor=#00FFFF;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="260" y="180" width="120" height="80" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="9" style="edgeStyle=none;html=1;exitX=0.5;exitY=1;exitDx=0;exitDy=0;exitPerimeter=0;entryX=1;entryY=0.5;entryDx=0;entryDy=0;entryPerimeter=0;endArrow=none;endFill=0;strokeColor=#0a0000;" edge="1" parent="1" source="3" target="4">
|
||||||
|
<mxGeometry relative="1" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="3" value="" style="fontColor=#0066CC;verticalAlign=top;verticalLabelPosition=bottom;labelPosition=center;align=center;html=1;outlineConnect=0;fillColor=#CCCCCC;strokeColor=#6881B3;gradientColor=none;gradientDirection=north;strokeWidth=2;shape=mxgraph.networks.wireless_hub;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="170" y="230" width="60" height="50" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="4" value="" style="fontColor=#0066CC;verticalAlign=top;verticalLabelPosition=bottom;labelPosition=center;align=center;html=1;outlineConnect=0;fillColor=#CCCCCC;strokeColor=#6881B3;gradientColor=none;gradientDirection=north;strokeWidth=2;shape=mxgraph.networks.pc;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="80" y="310" width="70" height="50" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="11" style="edgeStyle=none;html=1;exitX=0.88;exitY=0.5;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;entryPerimeter=0;endArrow=none;endFill=0;strokeColor=#000000;" edge="1" parent="1" source="5" target="6">
|
||||||
|
<mxGeometry relative="1" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="5" value="" style="fontColor=#0066CC;verticalAlign=top;verticalLabelPosition=bottom;labelPosition=center;align=center;html=1;outlineConnect=0;fillColor=#CCCCCC;strokeColor=#6881B3;gradientColor=none;gradientDirection=north;strokeWidth=2;shape=mxgraph.networks.proxy_server;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="425" y="195" width="60" height="50" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="12" style="edgeStyle=none;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;exitPerimeter=0;entryX=0;entryY=0.14;entryDx=0;entryDy=0;entryPerimeter=0;endArrow=none;endFill=0;strokeColor=#000000;" edge="1" parent="1" source="6" target="7">
|
||||||
|
<mxGeometry relative="1" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="6" value="" style="fontColor=#0066CC;verticalAlign=top;verticalLabelPosition=bottom;labelPosition=center;align=center;html=1;outlineConnect=0;fillColor=#CCCCCC;strokeColor=#6881B3;gradientColor=none;gradientDirection=north;strokeWidth=2;shape=mxgraph.networks.firewall;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="530" y="190" width="60" height="60" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="7" value="" style="fontColor=#0066CC;verticalAlign=top;verticalLabelPosition=bottom;labelPosition=center;align=center;html=1;outlineConnect=0;fillColor=#CCCCCC;strokeColor=#6881B3;gradientColor=none;gradientDirection=north;strokeWidth=2;shape=mxgraph.networks.server_storage;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="640" y="260" width="80" height="80" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="15" value="SrcHost" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontColor=#1b0490;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="85" y="360" width="60" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="16" value="DstHost" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontColor=#1b0490;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="640" y="340" width="60" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
<mxCell id="17" value="Bastion" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontColor=#1b0490;" vertex="1" parent="1">
|
||||||
|
<mxGeometry x="420" y="245" width="60" height="30" as="geometry"/>
|
||||||
|
</mxCell>
|
||||||
|
</root>
|
||||||
|
</mxGraphModel>
|
||||||
|
</diagram>
|
||||||
|
</mxfile>
|
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
|
@ -0,0 +1,84 @@
|
||||||
|
# SSH подключение через промежуточный узел без доступа к промежуточному узлу
|
||||||
|
|
||||||
|
Задача: обеспечить подключение к узлу в закрытом сегменте сети через промежуточный (bastion) узел. При этом закрыть возможность подключения к промежуточному узлу.
|
||||||
|
|
||||||
|
Упрощённая схема представлена на русунке
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Вводные данные
|
||||||
|
|
||||||
|
- `srchost` - узел с которого необходимо обеспечить подключение
|
||||||
|
- `jumpuser` - пользователь, который инициирует подключение
|
||||||
|
- `bastion` - промежуточный узел, через который необходимо обеспечить подключение
|
||||||
|
- `enduser` - пользователь, от имени которого необходимо выполнить подключение
|
||||||
|
- `dsthost` - узел, к которому необходимо подключиться
|
||||||
|
|
||||||
|
Порядок подключения:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
jumpuser@srchost:~$ ssh -A -J jumpuser@bastion enduser@dsthost
|
||||||
|
```
|
||||||
|
|
||||||
|
## Настройка подключения
|
||||||
|
|
||||||
|
### Сегенерировать ssh ключ
|
||||||
|
|
||||||
|
На узле `srchost` для пользователя `jumpuser` сгенерировать ssh-ключ
|
||||||
|
|
||||||
|
```shell
|
||||||
|
jumpuser@srchost:~$ ssh-keygen
|
||||||
|
```
|
||||||
|
|
||||||
|
### Скопировать публичный ключ на узел `bastion`
|
||||||
|
|
||||||
|
```shell
|
||||||
|
jumpuser@srchost:~$ ssh-copy-id jumpuser@bastion
|
||||||
|
```
|
||||||
|
|
||||||
|
### Проверить подключение
|
||||||
|
|
||||||
|
Убедиться, что есть возможность подключения без пароля
|
||||||
|
|
||||||
|
```shell
|
||||||
|
jumpuser@srchost:~$ ssh jumpuser@bastion
|
||||||
|
jumpuser@bastion:~$
|
||||||
|
```
|
||||||
|
|
||||||
|
### Скопировать публичный ключ на узел `dsthost`
|
||||||
|
|
||||||
|
Скопировать публичный ключ `jumpuser` в файл `/home/enduser/.ssh/authorized_keys` на узле `dsthost`
|
||||||
|
|
||||||
|
```shell
|
||||||
|
enduser@dsthost:~$ cat .ssh/authorized_keys
|
||||||
|
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDqAk2CZKveP6zvYKBlwxhlhontNHOpMiKdS1rIfJ8r5J9CHn3EbZftfwMIPp2dji4YsKkCHVEVHbwLf+efc/8wUxnaBdVZPaP/SUT9+f3NjjVxS7vPfIw24qHTltIIcJaeJMPHZ5BKtF9Gvgkh4N4MLH2e2o7OcekQej/JEQSDneqgEfPe5Xhks34VOOkhaM02skyFjCEacLBfBbYHqlwWDEEtUAMzQGdgt9h85WWcCBA/qRT8eRDvKFYEr7238jREKD0MPQ1R5jIjk37GFa0vr7vEAO9mTI4hGHl89YqnxaWg6P5gO+lXGsemE+0oXpWG7zKt8PF2nPK6dq93RFeb jumpuser@srchost
|
||||||
|
```
|
||||||
|
|
||||||
|
### Проверить подключение через промежуточный хост с пробросом ключа
|
||||||
|
|
||||||
|
```shell
|
||||||
|
jumpuser@srchost ~$ ssh -A -J jumpuser@srchost enduser@dsthost
|
||||||
|
enduser@dsthost ~$
|
||||||
|
```
|
||||||
|
|
||||||
|
### Ограничить возможность подключения пользователем `jumpuser` к `bastion`
|
||||||
|
|
||||||
|
В конфигурационный файл `/etc/ssh/sshd_config` добавить
|
||||||
|
|
||||||
|
```shell
|
||||||
|
jumpuser@bastion:~ $ tail -n 7 /etc/ssh/sshd_config
|
||||||
|
|
||||||
|
Match User jumpuser
|
||||||
|
PermitTTY no
|
||||||
|
X11Forwarding no
|
||||||
|
PermitTunnel no
|
||||||
|
GatewayPorts no
|
||||||
|
ForceCommand /usr/sbin/nologin
|
||||||
|
```
|
||||||
|
|
||||||
|
Таким образом получается подключиться к `enduser@dsthost` через промежуточный узел `jumpuser@bastion` без возможности подключения к `jumpuser@bastion`
|
||||||
|
|
||||||
|
```shell
|
||||||
|
jumpuser@srchost ~$ ssh -A -J jumpuser@srchost enduser@dsthost
|
||||||
|
enduser@dsthost ~$
|
||||||
|
```
|
Loading…
Reference in New Issue