From fa9fe33df76c3ce17648cbe3d562af21bf000197 Mon Sep 17 00:00:00 2001 From: Dinesh Kumar Date: Sat, 13 Oct 2018 13:37:42 +0530 Subject: [PATCH 1/7] Enable manual mode for entering password --- lazy-connect.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lazy-connect.sh b/lazy-connect.sh index e1d8531..cb4ad37 100755 --- a/lazy-connect.sh +++ b/lazy-connect.sh @@ -105,8 +105,10 @@ function _lazy_connect() { esac fi + [[ "$MANUAL_MODE" -eq "true" ]] && echo -n "$password" | pbcopy + osascript < Date: Sun, 14 Oct 2018 15:54:36 +0530 Subject: [PATCH 2/7] Rename MANUAL_MODE to AUTOFILL --- lazy-connect.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lazy-connect.sh b/lazy-connect.sh index cb4ad37..716619e 100755 --- a/lazy-connect.sh +++ b/lazy-connect.sh @@ -105,10 +105,10 @@ function _lazy_connect() { esac fi - [[ "$MANUAL_MODE" -eq "true" ]] && echo -n "$password" | pbcopy + [[ "$AUTOFILL" -eq "true" ]] && echo -n "$password" | pbcopy osascript < Date: Tue, 16 Oct 2018 14:34:56 +0530 Subject: [PATCH 3/7] Updating env variable with convention, and added instruction to readme --- README.md | 9 +++++++++ lazy-connect.sh | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e42d66a..3bb705a 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,15 @@ lazy-connect - Shell function to fuzzy search an IPSec VPN by name -h - Show this help ``` +## Configuration + +* The connection to VPN could be made with filling password automatically. To enable autofill set `LAZY_CONNECT_AUTOFILL` variable to true. + +``` +export LAZY_CONNECT_AUTOFILL="true" +``` +When disabled, the password is copied to clipboard, and you can use it manually when it prompts for password. + ### YubiKey Support #### Prerequisite diff --git a/lazy-connect.sh b/lazy-connect.sh index 716619e..b7b3647 100755 --- a/lazy-connect.sh +++ b/lazy-connect.sh @@ -105,7 +105,7 @@ function _lazy_connect() { esac fi - [[ "$AUTOFILL" -eq "true" ]] && echo -n "$password" | pbcopy + [[ "$LAZY_CONNECT_AUTOFILL" -eq "true" ]] && echo -n "$password" | pbcopy osascript < Date: Fri, 9 Nov 2018 15:12:23 +0530 Subject: [PATCH 4/7] adding -n flag to autofill the password, and making vars local to functions --- lazy-connect.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/lazy-connect.sh b/lazy-connect.sh index b7b3647..ffb1120 100755 --- a/lazy-connect.sh +++ b/lazy-connect.sh @@ -58,6 +58,7 @@ USAGE: lazy-connect - Shell function to fuzzy search an IPSec VPN by name and connect to it automatically. +-n - Connect to VPN by autofilling password -i - Initialize lazy-connect. Stores the secret and VPN list to ~/.config/lazy-connect/ -u - Update lazy-connect @@ -67,7 +68,7 @@ EOF } function _lazy_connect_get_totp() { - secret_key=$1 + local secret_key=$1 case $TOTP_MODE in oathtool) password=$(oathtool --totp --base32 $secret_key) @@ -89,7 +90,7 @@ function _lazy_connect_get_totp() { } function _lazy_connect() { - vpn_name=$1 + local vpn_name=$1 _lazy_connect_get_totp $2 if [ -z "$password" ]; then @@ -105,7 +106,11 @@ function _lazy_connect() { esac fi - [[ "$LAZY_CONNECT_AUTOFILL" -eq "true" ]] && echo -n "$password" | pbcopy + if [ "$3" = "true" ]; then + local _lazy_connect_auto_fill_pwd="true" + else + echo "$password" | pbcopy + fi osascript < Date: Tue, 13 Nov 2018 21:07:20 +0530 Subject: [PATCH 5/7] Updated readme with update and autoconnect options --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6b23927..d483552 100644 --- a/README.md +++ b/README.md @@ -33,8 +33,10 @@ sudo ln -s ~/.lazy-connect/lazy-connect /usr/local/bin/lazy-connect lazy-connect - Shell function to fuzzy search an IPSec VPN by name and connect to it automatically. --i - Initialize lazy-connect. +-n - Connect to VPN by autofilling password +-i - Initialize lazy-connect. Stores the TOTP secret and VPN list Stores the secret and VPN list to ~/.config/lazy-connect/ +-u - Update lazy-connect -r - refresh vpn list in ~/.config/lazy-connect -h - Show this help ``` From 3195476fb1a2ef520b52bff1975907f6887b9a98 Mon Sep 17 00:00:00 2001 From: Dinesh Kumar Date: Sat, 24 Nov 2018 20:07:53 +0530 Subject: [PATCH 6/7] Reading secret from keychain on auto connect --- lazy-connect | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lazy-connect b/lazy-connect index ef8f711..201959c 100755 --- a/lazy-connect +++ b/lazy-connect @@ -147,7 +147,7 @@ function lazy-connect() { local OPTIND mkdir -p $_lazy_connect_config_dir - while getopts "iruhn" opt; do + while getopts "irhn" opt; do case $opt in h) _lazy_connect_usage @@ -163,7 +163,7 @@ function lazy-connect() { return 0 ;; n) - local _secret=$(cat $_lazy_connect_config_dir/secret) + local _secret=$(security find-generic-password -a lazy-connect -w 2>/dev/null | tr -d '\n') local _vpn_name=$(cat $_lazy_connect_config_dir/vpns | fzf --height=10 --ansi --reverse --select-1) _lazy_connect "$_vpn_name" "$_secret" true return 0 From b2a0eb10e04dcc4bb307c096a1cc1b676c522674 Mon Sep 17 00:00:00 2001 From: Dinesh Kumar Date: Fri, 30 Nov 2018 19:29:52 +0530 Subject: [PATCH 7/7] Fix: remove newline in echo to copy --- lazy-connect | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lazy-connect b/lazy-connect index 201959c..38f14a5 100755 --- a/lazy-connect +++ b/lazy-connect @@ -113,7 +113,7 @@ function _lazy_connect() { if [ "$3" = "true" ]; then local _lazy_connect_auto_fill_pwd="true" else - echo "$password" | pbcopy + echo -n "$password" | pbcopy fi osascript <