Refactor folder structure.
[sim/o1-interface.git] / ntsimulator / deploy / tls / enable_ssh_key.sh
1 #! /bin/bash
2 ################################################################################
3 #
4 # Copyright 2020 highstreet technologies GmbH and others
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9
10 #     http://www.apache.org/licenses/LICENSE-2.0
11
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17
18 ################################################################################
19 # Script to enable SSH publicKey authentication in the localhost NETCONF server
20
21 sleep 5
22
23 SSH_PUB_KEY="$(cat /home/netconf/.ssh/id_dsa.pub| awk '{print $2}')"
24
25 echo '<system xmlns="urn:ietf:params:xml:ns:yang:ietf-system"><authentication><user><name>netconf</name><authorized-key><name>ssh_key</name><algorithm>ssh-dss</algorithm>' >> load_auth_pubkey.xml
26 echo '<key-data>'"$SSH_PUB_KEY"'</key-data></authorized-key></user></authentication></system>' >> load_auth_pubkey.xml
27
28 sysrepocfg --merge=load_auth_pubkey.xml --format=xml ietf-system
29 rm load_auth_pubkey.xml
30
31 ssh-keyscan -p 830 127.0.0.1 >> ~/.ssh/known_hosts
32
33 echo 'Done'
34 exit 0