๐Ÿ”’ Closed Script for ovpn

Status
Not open for further replies.

PHC-POLOY

Forum Veteran
IMG_20181031_205706_582.jpg Sa mga nagtatanong at nag PM sa akin kung ano ang script ko sa ovpn...napaka SIMPLE lang ang script ko..paki tingnan nalang sa screenshot...salamat..IMG_20181031_210320_910.jpg
 
Nice anong script ginamit mo sa vps? Yung sa Open Vpn?
Nagtry ako yung proxy same as openvpn server no luck dapat ba ibang vps yung proxy? If iba may script ka dyan pwede maka hinge? Thanks
 
Nice anong script ginamit mo sa vps? Yung sa Open Vpn?
Nagtry ako yung proxy same as openvpn server no luck dapat ba ibang vps yung proxy?
Kung saan kayo kumuha ng server sa mga ssh sites ay ganyan ang script...ang mahalaga dyan ay ang buong config ng ovpn kung saan kayo nag reg ng server...
 
Kung saan kayo kumuha ng server sa mga ssh sites ay ganyan ang script...ang mahalaga dyan ay ang buong config ng ovpn kung saan kayo nag reg ng server...
Oo alam ko alam mo ba yung script na gjnamit sa ovpn? Since madami script nagkalat ibat iba ang out ng config na nagegenerate gusto ko kasi malaman anong script ng ovpn na ginamit dyan ni TS
 
Oo alam ko alam mo ba yung script na gjnamit sa ovpn? Since madami script nagkalat ibat iba ang out ng config na nagegenerate gusto ko kasi malaman anong script ng ovpn na ginamit dyan ni TS
Magkaiba ang mga script sa vps at sa ssh sites...ang mahalaga dyan ay ang buong BEGIN CERTIFICATE...
 
Magkaiba ang mga script sa vps at sa ssh sites...ang mahalaga dyan ay ang buong BEGIN CERTIFICATE...
Pwede ko na tanggalin yung ibang script basta yung Certificate hindi? Nalilito kasi ako kapag may tls auth at cert key di ko tuloy mapagana yung sa Post mo TS ano ginamit na script dyan para makuha ko hehe
 
Ah okay thanks pero di ko kasi alam kung ano ginamit na script ng tcpvpn sa paggenerate sino may alam ? TIA gusto ko kasi sariling server
Code:
#!/bin/bash

# OpenVPN configuration Directory
OPENVPN_CFG_DIR=/etc/openvpn

# Directory where EasyRSA outputs the client keys and certificates
KEY_DIR=/etc/openvpn/easy-rsa/keys

# Where this script should create the OpenVPN client config files
OUTPUT_DIR=/etc/openvpn/client-config

# Base configuration for the client
BASE_CONFIG=/etc/openvpn/client-config/client.conf

# MFA Label
MFA_LABEL='OpenVPN Server'

# MFA User
MFA_USER=gauth

# MFA Directory
MFA_DIR=/etc/openvpn/google-authenticator

# ##############################################################################

function send_mail() {
  attachment=$1

  which mutt 2>&1 >/dev/null

  if [ $? -ne 0 ]; then
    echo "INFO: mail program not found, an email will not be sent to the user"
  else
    echo -en "Please, provide the e-mail of the user\n> "
    read email
    echo "INFO: Sending email"
    echo "Here is your OpenVPN client configuration" | mutt -s "Your OpenVPN configuration" -a "$attachment" -- "$email"
  fi
}

function generate_mfa() {
  user_id=$1

  if [ "$user_id" == "" ]; then
    echo "ERROR: No user id provided to generate MFA token"
    exit 1
  fi

  echo "INFO: Creating user ${user_id}"
  useradd -s /bin/nologin "$user_id"

  echo "> Please provide a password for the user"
  passwd "$user_id"

  echo "INFO: Generating MFA Token"
  su -c "google-authenticator -t -d -r3 -R30 -f -l \"${MFA_LABEL}\" -s $MFA_DIR/${user_id}" - $MFA_USER
}

function main() {
  user_id=$1

  if [ "$user_id" == "" ]; then
    echo "ERROR: No user id provided"
    exit 1
  fi

  if [ ! -f ${KEY_DIR}/ca.crt ]; then
    echo "ERROR: CA certificate not found"
    exit 1
  fi

  if [ ! -f ${KEY_DIR}/${user_id}.crt ]; then
    echo "ERROR: User certificate not found"
    exit 1
  fi

  if [ ! -f ${KEY_DIR}/${user_id}.key ]; then
    echo "ERROR: User private key not found"
    exit 1
  fi

  if [ ! -f ${OPENVPN_CFG_DIR}/ta.key ]; then
    echo "ERROR: TLS Auth key not found"
    exit 1
  fi

  cat ${BASE_CONFIG} \
      <(echo -e '<ca>') \
      ${KEY_DIR}/ca.crt \
      <(echo -e '</ca>\n<cert>') \
      ${KEY_DIR}/${user_id}.crt \
      <(echo -e '</cert>\n<key>') \
      ${KEY_DIR}/${user_id}.key \
      <(echo -e '</key>\n<tls-auth>') \
      ${OPENVPN_CFG_DIR}/ta.key \
      <(echo -e '</tls-auth>') \
      > ${OUTPUT_DIR}/${user_id}.ovpn

  echo "INFO: Key created in ${OUTPUT_DIR}/${user_id}.ovpn"

  generate_mfa $user_id
  send_mail "${OUTPUT_DIR}/${user_id}.ovpn"

  exit 0
}

# ##############################################################################

main $1


Ganito ba scripts?
 
Code:
#!/bin/bash

# OpenVPN configuration Directory
OPENVPN_CFG_DIR=/etc/openvpn

# Directory where EasyRSA outputs the client keys and certificates
KEY_DIR=/etc/openvpn/easy-rsa/keys

# Where this script should create the OpenVPN client config files
OUTPUT_DIR=/etc/openvpn/client-config

# Base configuration for the client
BASE_CONFIG=/etc/openvpn/client-config/client.conf

# MFA Label
MFA_LABEL='OpenVPN Server'

# MFA User
MFA_USER=gauth

# MFA Directory
MFA_DIR=/etc/openvpn/google-authenticator

# ##############################################################################

function send_mail() {
  attachment=$1

  which mutt 2>&1 >/dev/null

  if [ $? -ne 0 ]; then
    echo "INFO: mail program not found, an email will not be sent to the user"
  else
    echo -en "Please, provide the e-mail of the user\n> "
    read email
    echo "INFO: Sending email"
    echo "Here is your OpenVPN client configuration" | mutt -s "Your OpenVPN configuration" -a "$attachment" -- "$email"
  fi
}

function generate_mfa() {
  user_id=$1

  if [ "$user_id" == "" ]; then
    echo "ERROR: No user id provided to generate MFA token"
    exit 1
  fi

  echo "INFO: Creating user ${user_id}"
  useradd -s /bin/nologin "$user_id"

  echo "> Please provide a password for the user"
  passwd "$user_id"

  echo "INFO: Generating MFA Token"
  su -c "google-authenticator -t -d -r3 -R30 -f -l \"${MFA_LABEL}\" -s $MFA_DIR/${user_id}" - $MFA_USER
}

function main() {
  user_id=$1

  if [ "$user_id" == "" ]; then
    echo "ERROR: No user id provided"
    exit 1
  fi

  if [ ! -f ${KEY_DIR}/ca.crt ]; then
    echo "ERROR: CA certificate not found"
    exit 1
  fi

  if [ ! -f ${KEY_DIR}/${user_id}.crt ]; then
    echo "ERROR: User certificate not found"
    exit 1
  fi

  if [ ! -f ${KEY_DIR}/${user_id}.key ]; then
    echo "ERROR: User private key not found"
    exit 1
  fi

  if [ ! -f ${OPENVPN_CFG_DIR}/ta.key ]; then
    echo "ERROR: TLS Auth key not found"
    exit 1
  fi

  cat ${BASE_CONFIG} \
      <(echo -e '<ca>') \
      ${KEY_DIR}/ca.crt \
      <(echo -e '</ca>\n<cert>') \
      ${KEY_DIR}/${user_id}.crt \
      <(echo -e '</cert>\n<key>') \
      ${KEY_DIR}/${user_id}.key \
      <(echo -e '</key>\n<tls-auth>') \
      ${OPENVPN_CFG_DIR}/ta.key \
      <(echo -e '</tls-auth>') \
      > ${OUTPUT_DIR}/${user_id}.ovpn

  echo "INFO: Key created in ${OUTPUT_DIR}/${user_id}.ovpn"

  generate_mfa $user_id
  send_mail "${OUTPUT_DIR}/${user_id}.ovpn"

  exit 0
}

# ##############################################################################

main $1


Ganito ba scripts?
Anong Vps to Ubuntu 14 16 18? Oo nice
 
Ah okay thanks pero di ko kasi alam kung ano ginamit na script ng tcpvpn sa paggenerate sino may alam ? TIA gusto ko kasi sariling server
Ah okay thanks pero di ko kasi alam kung ano ginamit na script ng tcpvpn sa paggenerate sino may alam ? TIA gusto ko kasi sariling server
May sariling script ang bawat server kaya dapat idownload ng buo ang config na kasama na ang BEGIN CERTIFICATE....ang dapat nyo i-edit ay ang remote,user and pass,at remote proxy...un lang...idagdag lang ung custom header if naka reg ka sa mga promo ng mga networks...
 
May sariling script ang bawat server kaya dapat idownload ng buo ang config na kasama na ang BEGIN CERTIFICATE....ang dapat nyo i-edit ay ang remote,user and pass,at remote proxy...un lang...idagdag lang ung custom header if naka reg ka sa mga promo ng mga networks...
Paano yung TLS paano yung ibang Cert? Nagtry ako nyan ayaw gumana ang dami ng error kaya gusto ko sana yung script at yung config para isahan may script ka ba dyan dude pahinge ? At config thanks thanks
 
Status
Not open for further replies.

About this Thread

  • 29
    Replies
  • 2K
    Views
  • 14
    Participants
Last reply from:
iamemjayo8

Online now

Members online
735
Guests online
654
Total visitors
1,389

Forum statistics

Threads
2,275,125
Posts
28,960,808
Members
1,232,631
Latest member
marlaa1991
Back
Top