How to use openconnect to connect to vpn with 2 factor authentication with Google Authenticator - vpn

I would like to connect to vpn using opencoonect
Our company uses google authenticator codes

Use this to create 2 factor codes on your pc https://github.com/arcanericky/ga-cmd
Store your account password in ~/.cisco/pass.txt
Then use this to connect to vpn
echo -e "$(sudo cat ~/.cisco/pass.txt)\n$(./ga-cmd <your-ga-site-name>)" | sudo openconnect --user=<username> --passwd-on-stdin <your-vpn.com>

Or you can make it working with oathtool (works fine for macOS users):
alias vpn="echo -e '${YOUR_PWD}\n$(cat ~/.totp_google | xargs oathtool --totp -b)' | \
sudo openconnect {YOUR_VPN_HOST} --user=${YOUR_USERNAME} --passwd-on-stdin"
Your secret shoud be in ~/.totp_google file.

Related

How can determine managed identity of Azure VM a script is running on?

For post-processing of AzD=Azure Developer CLI I need to authorize the managed identity of the Azure VM, the script is currently running on, to the subscription selected by AzD. How can I determine managed identity of the VM with help of the metadata endpoint?
I created this script authorize-vm-identity.sh which determines the VM's resourceID (could be in a different subscription than the actual resources managed by AzD) from the metadata endpoint and then obtains the managed identities' principalId to make the actual role assignment with:
#!/bin/bash
source <(azd env get-values | sed 's/AZURE_/export AZURE_/g')
AZURE_VM_ID=`curl -s -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance?api-version=2021-02-01" | jq -r '.compute.resourceId'`
if [ ! -z $AZURE_VM_ID ];
then
AZURE_VM_MI_ID=`az vm show --id $AZURE_VM_ID --query 'identity.principalId' -o tsv`
fi
if [ ! -z $AZURE_VM_MI_ID ];
then
az role assignment create --role Contributor --assignee $AZURE_VM_MI_ID --scope /subscriptions/$AZURE_SUBSCRIPTION_ID
fi
Prerequisites:
Azure CLI
jq
curl

How do you access Airflow Web Interface?

Hi I am taking a datacamp class on how to use Airflow and it shows how to create dags once you have access to an Airflow Web Interface.
Is there an easy way to create an account in the Airflow Web Interface? I am very lost on how to do this or is this just an enterprise tool where they provide you access to it once you pay?
You must do this on terminal. Run these commands:
export AIRFLOW_HOME=~/airflow
AIRFLOW_VERSION=2.2.5
PYTHON_VERSION="$(python --version | cut -d " " -f 2 | cut -d "." -f 1-2)"
CONSTRAINT_URL="https://raw.githubusercontent.com/apache/airflow/constraints-${AIRFLOW_VERSION}/constraints-${PYTHON_VERSION}.txt"
pip install "apache-airflow==${AIRFLOW_VERSION}" --constraint "${CONSTRAINT_URL}"
airflow standalone
Then, in there, you can see the username and password provided.
Then, open Chrome and search for:
localhost:8080
And write the username and password.
airflow has a web interface as well by default and default user pass is : airflow/airflow
you can run it by using :
airflow webserver --port 8080
then open the link : http://localhost:8080
if you want to make a new username by this command:
airflow create_user [-h] [-r ROLE] [-u USERNAME] [-e EMAIL] [-f FIRSTNAME]
[-l LASTNAME] [-p PASSWORD] [--use_random_password]
learn more about Running Airflow locally
You should install it , it is a python package not a website to register on.
The easiest way to install Airflow is:
pip install apache-airflow
if you need extra packages with it:
pip install apache-airflow[postgres,gcp]
finally run the webserver and the scheduler in different cmd :
airflow webserver # it is by default 8080
airflow scheduler

How can I enable FTP/SFTP on Google Instance VM?

I'm trying to update WordPress, but it asks for FTP credentials.
I successfully changed the password using this command:
sudo passwd
and I entered the FTP credentials on the form but still can't update WordPress.
Here the instruction:
-1 ssh into the instance and run the below command
$ sudo su
$ apt-get update
$ apt-get install vsftpd
$ echo -e "pasv_enable=Yes\npasv_max_port=10101\npasv_min_port=10100\npasv_promiscuous=YES" >> /etc/vsftpd.conf
$ systemctl restart vsftpd
-2 Create a firewall rule and assign it to a target tag
gcloud compute --project=[your-project] firewall-rules create myftp --direction=INGRESS --priority=1000 --network=default --action=ALLOW --rules=tcp:20,tcp:21,tcp:10101 --source-ranges=0.0.0.0/0 --target-tags=ftp
-3 Add the firewall tag "ftp" to the drupal instance.
$ gcloud compute instances add-tags [vm-name] --zone=[vm-zone] --tags ftp
You have to make sure that you have an FTP server such as vsftp running on your VM. You can check by ssh-ing into your VM and running:
# ps aux | grep ftp
If there's no ftp server running, you need to configure and start it.
Also make sure that your GCP firewall settings allow FTP.
IN: TCP 20,21,60000-65535
OUT: TCP 20,21,60000-65535

Openstack-Folsom keystone script fail to configure

Based on this link https://github.com/mseknibilel/OpenStack-Folsom-Install-guide/blob/master/OpenStack_Folsom_Install_Guide_WebVersion.rst#openstack-folsom-install-guide , I tried running these scripts but it fails despite me setting the HOST_IP & EXT HOST_IP.
./keystone_basic.sh
./keystone_endpoints_basic.sh
Below is the error log received:-
-keystone:error:unrecognized arguments: service id of 18ea5916544429bed2c84af0303077
I have provide the information such as tenant_name, tenant_id and so on in a source file but it happens to be the script provided does not get recognized by the system. Below are the details of the OS I use.
I created VMs instead of using physical machines. Installed with Ubuntu 12.04 LTS.
Please advice on how to tackle this issue.
Thanks.
I had the same problem. I am using Ubuntu 12.04 LTS. After running:
keystone help user-create tenant id appears as follows:
Optional arguments:
...
--service_id <service-id>
Change --service-id to --service_id with a global replace
[Using command line]
# sed -i 's/--service-id/--service_id/g' /path/to/script.sh
restart keystone & It's database entries
mysql -u root -ppassword -e "drop database keystone"
mysql -u root -ppassword -e "create database keystone"
mysql -u root -ppassword -e "grant all privileges on keystone.* TO 'keystone'#'%' identified by 'password'"
mysql -u root -ppassword -e "grant all privileges on keystone.* TO 'keystone'#'localhost' identified by 'password'"
service keystone restart
keystone-manage db_sync

ssh login without any prompt

I have to login more then 150 sever and execute some unix commands.
The problem is, if I create a script which will run from one server and ssh login to 150 server and execute cmds and exit.
How can i login with any password prompt.
due to some reason i should not use ssh-keygen public and private key method , or use of some extra tool with bash line like "expect".
is there any normal way to do login through ssh in single command consisting username/password#servername like we have option in sqlplus and ftp.
There is a utility called sshpass that allows you to specify a password in the commandline.
Under Ubuntu/Debian install by using sudo apt-get install sshpass
sshpass -p 'abcedf' ssh joe#myserver.domain.com "df > ~/test; cat ~/test; rm ~/test;"
hope this helps
You can try setting up either ~/.shosts or /etc/ssh/shosts.equiv on each of your remote hosts. See man ssh under "AUTHENTICATION" for details.

Resources