#!/bin/bash

REMOTE_SERVER=$1

# Create a pipe
PIPE=$(mktemp -u)
mkfifo -m 600 $PIPE
# Attach it to file descriptior 3
exec 3<>$PIPE
# Delete the directory entry
rm $PIPE
# Write your password in the pipe
echo $INNO_K8S_PASSPHRASE >&3
# Connect with sshpass -d
sshpass -d3 \
    ssh root@$REMOTE_SERVER \
    -oStrictHostKeyChecking=no \
    -oUserKnownHostsFile=/dev/null \
    cat /root/.kube/config > kube.conf

# Close the pipe when done
exec 3>&-