Fuel rework for multiple libvirt
[armband.git] / patches / opnfv-fuel / 0004-post-scripts-Allow-SSH-on-non-admin-ifaces.patch
1 From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
2 Date: Tue, 12 Jul 2016 16:12:25 +0200
3 Subject: [PATCH] post-scripts: Allow SSH on non-admin ifaces.
4
5 By default, Fuel 9.0 configures iptables to only accept SSH connections
6 on admin interface.
7
8 If more than the admin interface is configured (e.g. by transplant script
9 or manually in fuel menu), whitelist SSH connections on all ifaces.
10
11 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
12 ---
13  .../post-scripts/10_accept_ssh_all_ifaces.sh       | 25 ++++++++++++++++++++++
14  1 file changed, 25 insertions(+)
15  create mode 100755 build/f_isoroot/f_bootstrap/post-scripts/10_accept_ssh_all_ifaces.sh
16
17 diff --git a/build/f_isoroot/f_bootstrap/post-scripts/10_accept_ssh_all_ifaces.sh b/build/f_isoroot/f_bootstrap/post-scripts/10_accept_ssh_all_ifaces.sh
18 new file mode 100755
19 index 0000000..b551516
20 --- /dev/null
21 +++ b/build/f_isoroot/f_bootstrap/post-scripts/10_accept_ssh_all_ifaces.sh
22 @@ -0,0 +1,25 @@
23 +#/bin/sh
24 +##############################################################################
25 +# Copyright (c) 2016 Enea AB and others.
26 +# Alexandru.Avadanii@enea.com
27 +# All rights reserved. This program and the accompanying materials
28 +# are made available under the terms of the Apache License, Version 2.0
29 +# which accompanies this distribution, and is available at
30 +# http://www.apache.org/licenses/LICENSE-2.0
31 +##############################################################################
32 +
33 +# Only mess with iptables if we have additional interfaces configured
34 +if grep -q "DEFROUTE=no" "/etc/sysconfig/network-scripts/ifcfg-eth0"; then
35 +  echo "iptables: Allow SSH connections on all interfaces"
36 +  # By default, Fuel 9.0 configures iptables to only accept SSH connections
37 +  # on admin interface. Whitelist SSH connections on all ifaces.
38 +  while [ $? -eq 0 ]; do
39 +    # First, try removing the rule we want to add to prevent duplicates
40 +    iptables -D INPUT -p tcp --dport ssh -j ACCEPT > /dev/null 2>&1;
41 +  done
42 +  iptables -A INPUT -p tcp --dport ssh -j ACCEPT
43 +  service iptables save
44 +  echo "iptables: Done configuring SSH"
45 +else
46 +  echo "iptables: Skipping configuring SSH for non-admin ifaces"
47 +fi