There is a handicraft script:
declare NAMECRT="dev" declare TYPECRT="client" declare -r SERVER="root@12.34.56.78" declare -r LOCALUSER="lu" declare -r REMOTEUSER="ru" #declare -r NAMESERVER="server_name" # Используется только при TYPECRT="server" su "${LOCALUSER}" -c " cd /home/"${LOCALUSER}"/easy-rsa-master/easyrsa3 [ ! -d /home/"${LOCALUSER}"/easy-rsa-master/easyrsa3/pki ] && ./easyrsa init-pki ./easyrsa gen-req "${NAMECRT}" " scp /home/"${LOCALUSER}"/easy-rsa-master/easyrsa3/pki/reqs/"${NAMECRT}.req" "${SERVER}":/home/"${REMOTEUSER}"/easy-rsa-master/easyrsa3/pki/reqs ssh "${SERVER}" " cd /home/"${REMOTEUSER}"/easy-rsa-master/easyrsa3/pki/reqs [ -f ./"${NAMECRT}.req" ] && chown -c "${REMOTEUSER}":"${REMOTEUSER}" ./"${NAMECRT}.req" su -l ca -c ' cd /home/"${REMOTEUSER}"/easy-rsa-master/easyrsa3 if [[ "${TYPECRT}" = "client" ]]; then ./easyrsa sign-req "${TYPECRT}" "${NAMECRT}" elif [[ "${TYPECRT}" = "server" ]]; then ./easyrsa sign-req "${TYPECRT}" "${NAMESERVER}" else echo "ERROR TYPECRT: ${TYPECRT}" exit 1 fi ' " if [[ "${TYPECRT}" = "client" ]]; then mkdir -p /etc/openvpn/"${TYPECRT}"/"${NAMECRT}" # develop.crt, ca.crt scp "${SERVER}":"/home/"${REMOTEUSER}"/easy-rsa-master/easyrsa3/pki/issued/"${NAMECRT}.crt" \ /home/${REMOTEUSER}/easy-rsa-master/easyrsa3/pki/ca.crt" /etc/openvpn/"${TYPECRT}"/"${NAMECRT}" # develop.key cp /home/${LOCALUSER}/easy-rsa-master/easyrsa3/pki/private/"${NAMECRT}.key" /etc/openvpn/"${TYPECRT}"/"${NAMECRT}" # ta.key if [ ! -f /etc/openvpn/server/ta.key ]; then cd /etc/openvpn/server/ openvpn --genkey --secret ta.key fi cp /etc/openvpn/server/ta.key /etc/openvpn/"${TYPECRT}"/"${NAMECRT}" elif [[ "${TYPECRT}" = "server" ]]; then # vpn_server.crt, crl.pem, ca.crt scp "${SERVER}":"\ /home/"${REMOTEUSER}"/easy-rsa-master/easyrsa3/pki/issued/"${NAMESERVER}".crt \ /home/"${REMOTEUSER}"/easy-rsa-master/easyrsa3/pki/crl.pem \ /home/"${REMOTEUSER}"/easy-rsa-master/easyrsa3/pki/ca.crt" /etc/openvpn/"${TYPECRT}" # server.key cp /home/"${LOCALUSER}"/easy-rsa-master/easyrsa3/pki/private/"${NAMECRT}".key /etc/openvpn/"${TYPECRT}" # dh.pem su "${LOCALUSER}" -c " cd /home/${LOCALUSER}/easy-rsa-master/easyrsa3 ./easyrsa gen-dh " cp /home/"${LOCALUSER}"/easy-rsa-master/easyrsa3/pki/dh.pem /etc/openvpn/"${TYPECRT}" else echo "ERROR" exit 1 fi if [ -d /etc/openvpn/"${TYPECRT}"/"${NAMECRT}" ]; then cd /etc/openvpn/client cp -r ./"${NAMECRT}" /home/${LOCALUSER}/down fi There is server A with VPN, there is server B with CA. The script is located on server A and is executed on it. The essence of the script is certificate generation. On server A, a request is generated, sent to server B, signed and returned. Everything works, everything is fine.
But there is an inconvenience - the password must be entered many times. Throw a key for ssh, a bad option, because if you screw it up, then one FIG will have to enter the password every time, and without the password, you would not want to do access from one server to another, otherwise the CA and VPN separation is lost.
The question is whether it is possible to do so that during the first connection the session is not lost and in the future it was possible to switch from the remote to the local server, execute commands and end the session after the end of the whole action?
ssh-agentis a utility that just allows you to request a password to the key once, and then safely (as far as possible) store it in memory in decrypted form and use when connecting. - Fat-Zerssh-keygen... - Fat-Zer