Mostly work related stuff which I would've entered into my "Log book". Instead of hosting it on an intranet site, outsourcing the hosting to blogger!
Sunday, February 21, 2021
mounting Azure blob storage
Fresh install of Moodle on Ubuntu 20.04 with apt
Using the command at https://www.tecmint.com/install-moodle-in-ubuntu/
sudo apt update
sudo apt install php-common php-iconv php-curl php-mbstring php-xmlrpc php-soap php-zip php-gd php-xml php-intl php-json libpcre3 libpcre3-dev graphviz aspell ghostscript clamav
Then git-based install after
sudo apt install git
Edit: For the error "PHP has not been properly configured with the MySQLi extension for it to communicate with MySQL. Please check your php.ini file or recompile PHP."
we can follow the installation instructions at
https://docs.moodle.org/310/en/Step-by-step_Installation_Guide_for_Ubuntu
Installing the lapp stack on Ubuntu 20
https://kb.amijani.net/web-server/how-to-install-lapp-apache-php-postgresql-on-ubuntu-20-04/
Basically,
sudo apt install apache2
sudo apt install php7.4 libapache2-mod-php7.4 openssl php-imagick php7.4-common php7.4-curl php7.4-gd php7.4-imap php7.4-intl php7.4-json php7.4-ldap php7.4-mbstring php7.4-pgsql php-ssh2 php7.4-xml php7.4-zip unzip
Then install PostgreSQL with
https://www.digitalocean.com/community/tutorials/how-to-install-postgresql-on-ubuntu-20-04-quickstart
Thursday, February 18, 2021
connecting to a pptp VPN
A VPN to some servers was configured on Windows 10 clients as
Type of sign-in info: User name and password
and under "Advanced",
VPN type: Automatic.
Other windows clients were able to log on to the VPN with no problems, but when I tried with Linux Mint and the default pptp VPN settings, the connection was failing. My first thought was that some setting was missing, but it turned out that the reason for the VPN to fail was that my internet connection was via a mobile hotspot - just connecting via a broadband connection did the trick, I did not have to do any port-forwarding or any settings on the router. And then I found that some mobile hotspots work too -
LG Q6 with Airtel 4G on primary SIM slot - no
LG Q6 with Airtel 3G on primary SIM slot - sometimes works.
Redmi 4 with Jio SIM - works
Realme U1 with Jio SIM in secondary SIM slot - no
JioFi router (2018 model) - works
BSNL ADSL broadband with wifi router - works
With the default routing, all connections are routed through the VPN, and normal internet browsing doesn't work. With the help of this post, changed the routing so that only connections to those machines which are on the VPN are routed through the VPN.
/var/log/syslog gave the internal gateway info, which is on the private subnet, different from the external gateway which is on a public subnet.
Wednesday, February 17, 2021
rsync, screen and ssh-agent
On some of our other Ubuntu servers, rsync in a cron job as root works fine with ssh and key-based authentication. But not on a CentOS server I recently logged on to, because ssh-agent was not automatically started on login.
So, I have to run the following -
eval `ssh-agent -s`
ssh-add /path/to/keyfile.pem
and then do the ssh -i keyfile user@remoteserver
Monday, February 15, 2021
php oauth server - link dump
PHP 5
https://www.sitepoint.com/creating-a-php-oauth-server/
https://bshaffer.github.io/oauth2-server-php-docs/
PHP 7
https://github.com/thephpleague/oauth2-server
Using firebase (PHP 7)
https://github.com/jeromegamez/firebase-php-examples
Edit: We finally did not use any of these, and instead authenticated using google sign-in against our own database as mentioned at https://hnsws.blogspot.com/2021/12/using-google-sign-in-for-our-php-portal.html
creating rectangular boxes with Gimp
Then, menu item Edit - Stroke selection
Friday, February 12, 2021
forcing chrome to reconnect to a website
HTTP to HTTPS redirection on Windows Server and IIS
RewriteCond %{SERVER_NAME} =whatever.tld
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
https://www.ssl.com/how-to/redirect-http-to-https-with-windows-iis-10/
- Download and install the URL Rewrite module
- In IIS Manager, choose the relevant website, double-click URL Rewrite
- Click Add Rules on RHS, create a Blank Rule in inbound section.
- Choose Requested URL: Matches Pattern and Using: Regular Expression, with the Pattern: (.*) and Ignore Case ticked.
- Logical Grouping: Match All, then Add...
- In the Add Condition box, Condition Input: {HTTPS}, Check if input string: Matches the Pattern, Pattern: ^OFF$, Ignore case: ticked.
- In the Action setting, Edit Inbound Rule, set Action type: Redirect, Rewrite URL: https://{HTTP_HOST}/{REQUEST_URI} , Append query string: uncheck, Redirect type: Permanent (301).
- Finally, click Apply in the Actions section on Right-hand side.
Thursday, February 11, 2021
scripts to alert admin when hard disk is full, and to delete older files
Proposed solution to alert admin when a server hard disk becomes close to full, and for auto deleting old files -
1. Script to email us when hard disk becomes full -
https://www.google.com/search?q=script+to+email+me+when+hard+disk+crosses+free
gives this script,
https://www.linuxjournal.com/content/tech-tip-send-email-alert-when-your-disk-space-gets-low
by adjusting the THRESHOLD=90 line, we can adjust when the script will email us. 10 GB out of 500 GB hard disk means we need to put THRESHOLD=98
#!/bin/bash
CURRENT=$(df / | grep / | awk '{ print $5}' | sed 's/%//g')
THRESHOLD=98
if [ "$CURRENT" -gt "$THRESHOLD" ] ; then
mail -s 'Disk Space Alert' mailid@domainname.com << EOF
Your root partition remaining free space is critically low. Used: $CURRENT%
EOF
fi
And a cron to run this daily like
@daily ~/ourScriptName.sh
2. Script to automatically delete files older than one month -
https://www.google.com/search?q=script+to+automatically+delete+files+older+than+one+month
gives us this,
https://tecadmin.net/delete-files-older-x-days/
which lists the steps manually.
If we just write this as a script and put a cron job like the earlier script, this should work. Something like
find /our/path -name "*.zip" -type f -mtime +30 -delete
error on booting Linux Mint 20
Hardware error might be fixed by zeroing out the partition and then reformatting, the last posts above indicate.
Tuesday, February 09, 2021
upgrade Linux Mint 18.3 to 20
https://community.linuxmint.com/tutorial/view/2416
Friday, February 05, 2021
icecast reload
kill -HUP processid
ps -A | grep icecast
ps -A | grep icecast
Edit - this followed the cat strategy at
https://forum.armbian.com/topic/11436-solved-icecast2-and-ssl/
Monday, February 01, 2021
too many authentication failures with ssh
Sunday, January 31, 2021
monitoring icecast stream with uptimerobot
Just a reminder to myself that the uptimerobot monitor for Icecast streams has to be a GET monitor, because Icecast sends a 400 Bad request error for HEAD requests. So, for example, we can set up a GET monitor for
https://streamingurl.tld/mountpoint/status.xsl
But then we would not really know if the streams are running - for that, we rely on our shell scripts to email us like
COULD NOT FIND PLAYLIST nameof.playlist AT Sun May 28 06:01:01 IST 2017
PLAYING EMERGENCY INSTRUMENTAL PLAYLIST!!
Friday, January 29, 2021
another domain name for the same page, implemented with Plesk
We wanted the same content as oldname.tld/url to be served from newname.tld/url for a domain which was being served from a shared server running Plesk. We could not do it by adding a domain alias, instead we had to do it by adding newname.tld as a new domain in Plesk and pointing it to the same directory as oldname.tld for wwwroot.
creating a Linux filesystem on a VHD file
In order to create a timeshift backup before upgrade, creating a virtual hard disk volume,
https://www.tecmint.com/create-virtual-harddisk-volume-in-linux/
This took 20 minutes on lenovo pc for 30 GB. mkfs finished in just seconds.
Thursday, January 28, 2021
fiber link tests
Wednesday, January 27, 2021
Google Forms for creating a feedback form
Initially, I thought our non-profit edition of Google Workspace did not have Google Forms, and so created a form manually, following
https://dev.to/omerlahav/submit-a-form-to-a-google-spreadsheet-1bia
https://github.com/jamiewilson/form-to-google-sheets
and a template from jotform.com
google apps scripts limitation on multiple logins
https://www.demandsage.com/blog/google-multi-account-authentication-bug-what-it-is-possible-workarounds/
"Sorry, unable to open the file at present.
Monday, January 18, 2021
renewing a dot tk domain
Freenom is the domain registrar for .tk and currently, their process for renewing free domains is -
- we get a reminder email 2 weeks before expiry
- free renewal is possible only 2 weeks before expiry
- the current link to renewal is via the Services menu item - Services -> Renew domains and not via "My Domains" as mentioned in their email.
Sunday, January 17, 2021
exploring creating issues on github using email
https://ifttt.com/applets/TKuX3JY6-create-github-issue-via-email
Saturday, January 16, 2021
adding SSL (https) to http mp3 streams - Apache reverse-proxy and letsencrypt
Our audio streams were getting blocked by Chrome's insistence on https. Our initial workaround was to not use any javascript-based player, and instead just use a link to the stream URL with target = _blank to open it in a new window or tab. Now, working towards https support for our audio streams, we found two options.
1. Icecast 2.4.4 has support for SSL, but we need to recompile it on most platforms with the flag set as the icecast package which is available at this repo doesn't support SSL. ./configure --with-curl --with-openssl
2. The other option is to use an SSL reverse-proxy - Apache or Nginx.
Since we had Apache running on our server already, I tried the reverse-proxy method. I had to use acme.sh and not certbot since our server needs an OS upgrade. After the acme.sh installation, have to log out and log in (or open another shell) for the .bashrc changes to take effect. On the server, the main steps were:
a2enmod proxy
a2enmod proxy-http #(without this, got Internal Server Error)
service apache2 restart
a2ensite stream.ourdomain.tld
service apache2 reload
The file created for stream.ourdomain.tld in /etc/apache2/sites-available/stream.ourdomain.tld.conf was copied from another virtual host and then I added the lines like
ProxyPass /nameofstream http://11.22.33.44:8567/
ProxyPassReverse /nameofstream http://11.22.33.44:8567/
ProxyPass /nameofanotherstream http://11.22.33.44:8577/
ProxyPassReverse /nameofanotherstream http://11.22.33.44:8577/
</VirtualHost>
The file created for the ssl version had to be hand-written since acme.sh doesn't automatically create the config files unlike certbot. stream.ourdomain.tld-ssl.conf had the additional lines
<IfModule mod_ssl.c>
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /etc/ssl/certs/stream.ourdomain.tld.cer
SSLCertificateKeyFile /etc/ssl/private/stream.ourdomain.tld.key
So, with acme.sh, first issued the certificate in Apache mode as root -
acme.sh --issue --apache -d stream.ourdomain.tld
and then installed it using
acme.sh --install-cert -d stream.ourdomain.tld \
--cert-file /etc/ssl/certs/stream.ourdomain.tld.cer \
--key-file /etc/ssl/private/stream.ourdomain.tld.key
a2ensite stream.ourdomain.tld-ssl
service apache2 reload
Worked.
Everything seems to be fine - Apache was not having any issues I could detect with top and a tail -f of the Apache access log. Cloudflare proxying had been turned on, but I'm not sure if it had any impact since this was a stream and not a static file which could have been cached.
CPU utilization and RAM utilization didn't change more than 1-2% - 97% idle CPU, and all the Apache processes together were using only 14% RAM or less of our 8 GB server, which didn't increase substantially from what it was before the test. Some 300+ clients connected via our website with the new links to the various streams in the last 90 minutes or so of the test.
Edit: See the later post, implemented with icecast-kh
https://hnsws.blogspot.com/2021/06/adding-ssl-https-to-http-mp3-streams.html
Monday, January 11, 2021
github phasing out password authentication for commits
While making some command-line commits to github, I'd received an email from github that password-based authentication is deprecated, and would be unavailable after Aug 2021. Github docs also mention that pw auth is deprecated. This stackoverflow post also discusses the change, and its advantages. So, basically we need to create the password token, give it suitable permissions and use that instead of the password on the commandline.
Sunday, January 10, 2021
centre-click for restoring xfce minimized windows
Working with xfce on a GCP cloud server, minimized windows were not visible. My workaround as suggested by this forum post was to centre-click on the desktop (right+left click on my trackpad) and choose the relevant window from the list.
RDP failure and resolution
Last week, I could not remote desktop into one of our servers which was a VM on Azure - Remote Desktop was working only immediately after a restart, and later not at all. Remmina failed with
connected to ip.address.tld:3389
recv: Connection reset by peer
Error: protocol security negotiation or connection failure
and rdesktop failed with
ERROR: CredSSP: Initialize failed, do you have correct kerberos tgt initialized ?
Failed to connect, CredSSP required by server.
I thought I got the explanation for CredSSP from this post and thought disabling NLA would solve the issue. But then, I could not connect at all. I'd done this by right-clicking on System, Properties, Remote, and disabling the check-box 'Allow connections only from computers with NLA...'
Tried resetting the connection configuration from Azure portal, still no. (Choose the VM in Azure Portal, Support + Troubleshooting, Reset Password screen, choose 'Reset configuration only').
I tried logging on using a Windows 10 VM on another server, but got an "internal error". Perhaps this was due to the Windows trial license expiring on that machine. Today when I re-installed a trial version of Windows 10 and tried to connect, the Remote Desktop connection worked fine. Turned on NLA, it still worked. Tried with Remmina on my local machine, that also worked.
So, why did it fail and why did it start working again? Was it due to a Windows update causing issues like in this forum thread? Perhaps a network glitch? Perhaps restarting the VM (which I did several times) or resetting the configuration solved the issue but I was unable to check due to turning off NLA? At that time, I did not see this post, but maybe in the future I might need these tips again.
Thursday, January 07, 2021
port forwarding workaround
One of our external IP addresses had port-forwarding set up to allow incoming ssh. That external network failed and the alternate network took over for web browsing, but our ssh connections would fail. Workaround was to set up identical port-forwarding rules for this alternate network external IP address also. Then, if the primary network fails, we can ssh in using the alternate network.
Tuesday, January 05, 2021
recommended font sizes for responsive websites
Troubleshooting an issue of iSpring's output html not appearing properly on a mobile app, found this page with some recommendations on font sizing for mobile devices. The issue itself might be due to javascript support issues or user-agent issues, I guess, since the page appears properly on mobile browsers.
Tuesday, December 29, 2020
importing emails into google groups
Sending invites to a large number of email ids from google groups, found the following.
- The "500 per day" limit seems to include those email ids which were selected for sending, and then were not sent since they were already members of the group.
- So, sending invites one by one - only one email at a time - would result in the maximum invites sent per day. But - this is very time consuming. Even with an automated script made with SikuliX, approximately 15 seconds per email id if processing one email at a time.
- Filtering out existing users makes the process much smoother. Script for that shared below. But the list still needs manual filtering of typos like gamil.com or gmailcom or gmail com etc.
=IF(ISERROR(MATCH(A143,Sheet2!B142:B,0)),"",A143)
Friday, December 25, 2020
GCP costs for 2 16 GB VMs
Google Cloud Platform's Billing -> Overview shows the number of free credits remaining as well as the number of days remaining.
Running 2 instances of e2-highmem-2 (2 vCPUs, 16 GB memory) cost approximately Rs. 600 or US$8 per day, or $250 per month, or $3000 per year.
URL addressability API removed from Alfresco
URL Addressability API (superseded by WebScripts)
Interestingly, this is in version 5-0-b. But ticket-based addressing of image URLs is working locally (I believe?) in 5-0-d. Does Alfresco's versioning go from d to c to b? Or is my understanding of the URL Addressability flawed?
The URL addressability documentation says that it has been obsoleted - 5
https://hub.alfresco.com/t5/alfresco-content-services-hub/url-addressability/ba-p/291489
Wednesday, December 23, 2020
mounting remote volumes and cloud drives - sshfs and rclone
Rclone can mount a wide variety - over 40! - of cloud storage options as drives on Linux, Windows and Mac. If we're ssh-ing into a remote machine and want to authenticate, we can tunnel the temporary web server which Rclone opens on port 53682.
Another option for remote mounting is sshfs.
When I tried it with key-based authentication,
sudo sshfs -o allow_other,default_permissions,IdentityFile=~/.ssh/id_rsa bitnami@xxx.xxx.xxx.xxx:/ /mnt/mymount
I got errors - connection reset by peer.
Apparently, the full path to the key file is needed -
sudo sshfs -o allow_other,default_permissions,IdentityFile=/home/myhomedir/.ssh/id_rsa bitnami@xxx.xxx.xxx.xxx:/ /mnt/mymount
Then it worked.
Monday, December 21, 2020
deploying war files on wildfly
https://www.baeldung.com/jboss-war-deploy
/opt/bitnami/ctlscript.sh stop wildfly
on Bitnami Wildfly VM.
Monitoring the log is a good way to judge if Wildfly is running or stopped -
sudo tail -f /opt/bitnami/wildfly/standalone/log/server.log
wildfly/standalone/deployments/CAS.war/WEB-INF/deployerConfigContext.xml
wildfly/standalone/deployments/CAS.war/WEB-INF/cas.properties
wildfly/modules/org/CustomAppName/properties/configuration/main/Environment.properties
location of Apache configuration files on Bitnami Wildfly VM and easy SSL configuration with LetsEncrypt
As of this writing in Dec 2020, this discussion on configuring redirects is not directly applicable to Bitnami's Wildfly VM. The Proxy Pass commands etc are located in /opt/bitnami/apache2/conf/vhosts/wildfly-http-vhost.conf
and
wildfly-https-vhost.conf
Bitnami makes it easy for us to use https by providing an interactive script which will set up SSL certificates with LetsEncrypt as well as a cron job for renewal -
sudo /opt/bitnami/bncert-tool
Sunday, December 20, 2020
check if a service is running
One way to easily check for a service listening on a port for a Linux server running systemd is using ss - need not be run as root.
ss -tulpn
shows all listening ports
ss -tulpn | grep 5432
would indicate if PostgreSQL is running or not, and so on.
Saturday, December 19, 2020
quick temporary phpPgAdmin installation using Bitnami
On Bitnami's Alfresco VM, installing phppgadmin using
sudo apt-get install phppgadmin
causes problems since apt-get on the platform (Debian 10) tries to install apache2 which is already installed as httpd on the Bitnami stack.
Bitnami's LAPP stack has phpPgAdmin, so one can install it as a user, disable or stop postgres from that stack, change phppgadmin/htdocs/ conf file for accessing any other db which we may have, change apache's port if another server is running at 8080, to 18080 for example, by modifying
apache2/conf/httpd.conf
and
apache2/conf/bitnami/bitnami.conf
Virtual hosts, host alias equivalents and LetsEncrypt SSL for IIS on Windows Server
The equivalent of adding virtual hosts in Apache is adding Sites in IIS. And similar to adding a host alias, what is done is to add a site binding. IIS Manager -> Servername -> Sitename -> Edit site
https://weblog.west-wind.com/posts/2016/feb/22/using-lets-encrypt-with-iis-on-windows
suggests using LetsEncrypt-Win-Simple which is now WinAcme. Very simple interactive script as described on their website.
Friday, December 18, 2020
Bitnami Wildfly VM default user is called user and not manager
Bitnami's documentation mentions that the username to access the wildfly admin console is manager. But with the credentials supplied, I was unable to log on to the VM deployed using GCP marketplace (Version: 21.0.2-0-r02). Then, looking at how to change the credentials, looking at the file /opt/bitnami/wildfly/standalone/configuration/mgmt-users.properties found that the username is actually user and not manager. Then I was able to log on.
Wednesday, December 16, 2020
Monitoring RAM usage of a VM on GCP
CPU usage is shown by default on the monitoring console, but in order to see how much RAM is used by a VM on Google Cloud Platform, one has to first install the agent, then in the Monitoring dashboard, open Metrics explorer, choose the GCE VM Instance Resource Type and choose the agent called Memory Usage (agent.googlapis.com/memory/bytes_used). This last part is a bit non-intuitive, because there are many entries labelled Memory Usage, and we have to scroll down till agent.googlapis.com/memory/bytes_used. The resulting chart can be saved to an existing dashboard or we can create a new dashboard.
tried and failed to change Alfresco port in Bitnami VM
The path above is tomcat/shared/classes/alfresco/web-extension/share-config-custom.xml
/opt/bitnami/apache2/conf/bitnami/bitnami.conf
had a line
ProxyPass ajp://localhost:8009/alfresco etc.
Tuesday, December 15, 2020
MySQL and PostgreSQL command line cheat sheet
MySQL
mysql -u root -p
(or bitnami user for bitnami VMs)
show databases;
use dbname1;
show tables;
create database dbname;
use dbname;
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password';
Example SQL script import usage
mysql -u username -p < example.sql
And if required,
drop table tablename;
or
drop database dbname;
PostgreSQL
For Debian-based distributions,
sudo apt-get install postgresql-client
psql -h <REMOTE HOST> -p <REMOTE PORT> -U <DB_USER> <DB_NAME>
\l
to show databases, or
select datname from pg_database;
And to show tables,
\c databasename
\dt
Edit: For exporting the database, various options for pg_dump, most common would be
sudo su postgres
pg_dump dbname > dumpfile.sql
or if local authentication is not supported in the hba.conf, and username/pw auth is supported,
pg_dump --no-owner --dbname=postgresql://dbuser:dbuserpasswd@host:port/dbname > dump.sql
From bash shell, as postgres user, can import like
psql dbname < dbdump.sql
From https://medium.com/coding-blocks/creating-user-database-and-adding-access-on-postgresql-8bfcd2f4a91e
create database dbname;
create user username;
(To change, alter user username with encrypted password 'MyPassWord';)
grant all privileges on database dbname to username;
If the database was imported as postgres user, and another user is given all privileges as above, a possible issue is "permission denied when accessing schema postgres". My rough workaround was to create another super user (since I did not know the postgres user's password and didn't want to change it and potentially break things) by logging on as root, su postgres, and
CREATE USER newadmin WITH SUPERUSER PASSWORD 'newadminpassword';
changing bitnami alfresco db to postgresql and resetting the password
After following the steps below, was unable to log on as alfresco admin user - the credentials were not being accepted. The solution is at the end of the post.
https://docs.alfresco.com/4.0/tasks/postgresql-config.html
https://computingforgeeks.com/install-postgresql-11-on-debian-10-buster/
To set the postgres alfresco user password MyPassWord
sudo su -
sudo postgres
psql
alter user alfresco with password 'MyPassWord';
Downloaded driver from
https://jdbc.postgresql.org/download.html
https://docs.bitnami.com/bch/infrastructure/tomcat/get-started/get-started/
says TOMCAT_HOME is /opt/bitnami/tomcat
but for the Bitnami Alfresco Community VM, found it was
/opt/bitnami/apache-tomcat
https://docs.alfresco.com/6.1/reuse/conv-syspaths.html
indicates location of <classpathRoot> as tomcat/shared/classes, so on this bitnami VM,
/opt/bitnami/apache-tomcat/shared/classes
Ask the database the location of pg_hba.conf as mentioned at
https://askubuntu.com/questions/256534/how-do-i-find-the-path-to-pg-hba-conf-from-the-shell
In our case doing
psql -t -P format=unaligned -c 'show hba_file';
as postgres user,
sudo nano /etc/postgresql/11/main/pg_hba.conf to add the line
host all all 127.0.0.1/32 password
and
systemctl restart postgresql
Then, restarting alfresco with
/opt/bitnami/ctlscript.sh restart
brings up alfresco by bootstrapping the required tables in the new database, but can't log in - the credentials are not accepted.
Tried various methods as given at https://docs.alfresco.com/5.1/concepts/admin-password.html and http://www.giuseppeurso.eu/en/alfresco-tips-and-tricks-1-reset-the-admin-password/ using hashes as given at https://blog.atucom.net/2012/10/generate-ntlm-hashes-via-command-line.html and so on. But did not work.
The solution was:
Delete or comment out the line with admin credentials at /opt/bitnami/apache-tomcat/shared/classes/alfresco-global.properties like
#alfresco_user_store.adminusername=admin
#alfresco_user_store.adminpassword=209c6174da490caeb422f3fa5a7ae634
so that when alfresco is restarted with
/opt/bitnami/ctlscript.sh restart
with a blank database, the admin username and password is reset to admin admin. After logging in, the password can be set as desired from the web console.
Saturday, December 12, 2020
Installing activemq on Debian 10
https://www.howtoforge.com/tutorial/debian-activemq-message-broker/
ERROR: Configuration variable JAVA_HOME or JAVACMD is not defined correctly. (JAVA_HOME='', JAVACMD='java')
https://stackoverflow.com/questions/31400148/apache-activemq-5-11-1-doesnt-start-in-ubuntu
in this case, for the bitnami stack, I defined JAVA_HOME and JAVACMD in /etc/default/activemq as
public key authentication fails with agent refused operation
I generated a private+public key pair on a Windows 10 machine, copied the key over to a Linux Mint 18.03 (based on Ubuntu Xenial 16.04) machine and used it to ssh into that machine with no issues. Then I generated another key pair on another Windows 10 machine, which had been upgraded to 10 from a lower version of Windows, and tried to use that key pair to log on to that machine from the Linux machine, but it failed with "agent refused operation".
Looked at various possible reasons for this failure, finally found that the private key was of a different size, and also had the string OpenSSH PRIVATE KEY instead of RSA PRIVATE KEY at the beginning and end. This might have been due to a different OpenSSH server from MLS software I had tried installing on the 2nd Windows machine, or it could have been due to something else. Anyway, I just created one more key from the 1st Windows machine and used that key pair instead for authenticating into the 2nd machine. That worked fine.
Edit - This discussion seems to be related, and has an explanation.
Thursday, December 10, 2020
Load testing a moodle server - log in with token parsed with Beautiful Soup
While trying automated logins with a simplistic python script like this -
import requests
url = 'https://theserver.tld/login/index.php'
myobj = {'username': 'theUserName', 'password': 'ThisIsThePassWord!', "logintoken": "hCBVa2gzAWqSa2u7iNzdzlE9kwpVehFf"}
x = requests.post(url, data = myobj)
print(x.text)
Moodle would return authentication failure - it was checking the logintoken, which was hard-coded above. R used a modified script to get the logintoken correctly first, which then works -
import sys
import requests
from bs4 import BeautifulSoup
#driver = webdriver.Chrome()
# using this technique, the testing machines would run out of RAM
# after a dozen or so Chrome instances were loaded!
#def login(url,usernameId, username, passwordId, password, submit_buttonId):
# driver.get(url)
# driver.find_element_by_id(usernameId).send_keys(username)
# driver.find_element_by_id(passwordId).send_keys(password)
# driver.find_element_by_id(submit_buttonId).click()
#myMoodleEmail = sys.argv[1]
#login("https://server.tld/login/index.php", "username", myMoodleEmail, "password", "ThePW!", "loginbtn")
#driver.close()
login_data = {
#'logintoken': 'XPc8nw0a2gLXpgsn6njpehwEoW43mzYQ',
'username': sys.argv[1], 'password': 'ThePW!'
}
headers = {'user-agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Mobile Safari/537.36'}
with requests.Session() as s:
url = "https://theserver.tld/login/index.php"
r = s.get(url)
soup = BeautifulSoup(r.content, 'html5lib')
login_data['logintoken'] = soup.find('input', attrs = {'name': 'logintoken'})['value']
r = s.post(url, data = login_data, headers = headers)
print(r.text)
So I didn't have to try JMeter as the moodle documentation suggests,
https://moodle.org/mod/forum/discuss.php?d=313489
which points to the moodle documentation on load testing.
https://docs.moodle.org/dev/JMeter#Make_JMeter_test_plan
Edit: Example usage of JMeter -
jmeter -n -t [jmx file] -l [results file] -e -o [Path to web report folder]
Edit: The final result was, on AWS, "R5A Quadruple Extra Large - 128 GB RAM, 16 Virtual CPUs, 10 GB Network" - for 2000 users to log in concurrently.
some ssh tunnel notes
While setting up an ssh server on Windows, found that PermitTunnel is not supported by the Microsoft port of OpenSSH-Server. But then, PermitTunnel is not required to do local port forwarding at the client side, like
ssh -L 5990:192.168.12.34:5990 user@server.name
And interestingly, this sort of "poor man's VPN" using such an ssh tunnel seems to be much faster than OpenVPN etc as mentioned here, due to having less overhead.
Tuesday, December 08, 2020
Installing OpenSSH on Windows 10 which had been upgraded from Windows 7
Add-WindowsCapability -Online -Name OpenSSH*
Friday, December 04, 2020
avoiding multiple redirects in cloudflare
Changing the SSL settings from Flexible to Strict fixed the too many redirects error for one of the domains - https://support.cloudflare.com/hc/en-us/articles/115000219871-Troubleshooting-redirect-loop-errors
Wednesday, November 25, 2020
adding share links
Used this medium post which links to this codepen as a starting point for implementing share over email (a mailto link), copy to clipboard, and sharing via facebook, twitter and linkedin. Our code is on my (private) github repo.
Monday, November 23, 2020
firebase authentication tutorial without the need to set up billing - but ...
The official firebase auth tutorial from Google needs you to set up billing. This tutorial made by the community doesn't need you to set up billing.
But since it's based on old versions of libs, with the current (newer) version of falcon, gives error at
from falcon.version import __version__ # NOQA
Saturday, November 21, 2020
exporting users from a large google group
Thursday, November 19, 2020
low cost video capture and streaming
How times have changed since the days of the $1000 Matrox RT2000 which we purchased in 1999-2001. This HDMI frame-grabber costs only $35. But it's just a simple HDMI to USB conversion, raw frames with no encoding. So the PC needs to be capable enough to handle the high-bitrate stream and do encoding on the fly. Since these are generally used by gamers for streaming, beefy machines are not an issue. And OBS Studio is the software of choice. Then, OBS Studio has "BrowserSource" which can be used to capture - no hardware required, except OBS Studio's own hardware requirements.
All these could be possibilities if Google goes ahead with its plan to remove access to Google Meet recording ability for Education customers.
Sunday, November 15, 2020
creating and distributing private keys as pem files
setting up letsencrypt certificates for multiple virtual hosts with apache
The preferred method is to just run certbot multiple times with each required domain, as mentioned at https://www.digitalocean.com/community/tutorials/how-to-set-up-let-s-encrypt-certificates-for-multiple-apache-virtual-hosts-on-ubuntu-14-04
So, sudo certbot --apache -d example.com -d www.example.com
and later
sudo certbot --apache -d example2.com -d www.example2.com
or whatever. And then add to root's cron,
15 3 * * * /usr/bin/certbot renew --quiet
which checks every morning at 3:15 AM and renews any certs with validity less than 30 days more.
Saturday, November 14, 2020
troubleshooting a ruby on rails web server
To troubleshoot a web server running ruby on rails, checked the history of the ssh login I had been supplied (up arrow, up arrow, etc) and found that the admin had started rails using
rails s -p 5001 -b <ipaddress> -d
rails s -p 3001 -b <ipaddress> -d
for the two sites, and that they were running apache to proxy these ports to the two websites. The sites-available had virtual hosts configured like
DocumentRoot /full/path/to/rubyonrails/project/production
...
ProxyPass / http://xx.yy.zz.ww:5001/
ProxyPassReverse / http://xx.yy.zz.ww:5001/
and so on.
Found that the apache sites-enabled directory had some wrong entries + duplicate entries, which were causing apache to go back to the default configuration with no virtual servers, hence the various errors. There may be some issues with apache, serveralias and rails as mentioned here,
https://serverfault.com/questions/300226/serving-rails-through-apache-using-proxypass
that it was serving up the test page when the main domain was a server alias. So, I created a separate virtual server conf file in sites-available, with main-domain-name.conf which solved that issue. Then ran certbot for both domains for getting letsencrypt certificates.
Tuesday, November 10, 2020
debugging the radiosai google assistant action's audio search issue
Going step by step, found that dialogflow was returning the value "search" instead of the words the user was using. After going through the codelabs example at https://codelabs.developers.
After submitting this version as a release, the corrected version is live now.
Monday, November 09, 2020
test of creating a free tier instance, using it for multiple users like students
Though GCP's "recommended way" of adding SSH keys is quite convoluted, found that I could use my usual method to add my key, and use PasswordAuthentication yes in /etc/sshd-config to allow password-based logins for users.
As can be seen in this techrepublic post, the way to prevent newly created users from seeing each others' directories is to edit the /etc/adduser.conf file, changing the default home directory permissions from 755 to 750. We can of course do this manually with sudo chmod 750 /home/user1 and so on.
Then, using a "Free Tier" f1 micro instance, someone can do text-based teaching like conducting a C lab after installing the required build tools like apt install gcc or apt-get install build-essential. Currently the specs of a free tier compute instance are -
1 F1-micro instance per month
Scalable, high-performance virtual machines.
1 non-preemptible f1-micro VM instance per month in one of the following US regions:
Oregon: us-west1
Iowa: us-central1
South Carolina: us-east1
30 GB-months HDD
5 GB-month snapshot storage in the following regions:
Oregon: us-west1
Iowa: us-central1
South Carolina: us-east1
Taiwan: asia-east1
Belgium: europe-west1
1 GB network egress from North America to all region destinations (excluding China and Australia) per month.
Saturday, November 07, 2020
Azure AD guest account and how to close an azure account
There are conflicting posts all around, saying that one can only remove subscriptions and not close an Azure account once it is opened. Since I had used this from a test domain, it was an "unmanaged organization"
https://docs.microsoft.com/en-us/azure/active-directory/enterprise-users/users-close-account
Sign in to close your account, using the account that you want to close.
On My data requests, select Close account.

I used this to remove the test account I had created to delegate permissions for an app being developed by a third-party. The delegation of permissions via Azure Active Directory implies that the guest user has to switch directory to the directory of the current resource in the Azure portal, and then the guest user would have view access to the current directory name (and probably more).
Monday, November 02, 2020
diffuse not opening - needs python2
The graphical diff tool Diffuse was not opening - running it from the terminal gave the error message
diffuse
File "/usr/bin/diffuse", line 74
print codecs.encode(unicode(s, 'utf_8'), sys.getfilesystemencoding())
^
SyntaxError: invalid syntax
Apparently this is because diffuse is written for python2.
So, edited the hashbang for /usr/bin/diffuse to use /usr/bin/env python2 instead of /usr/bin/env/ python, works now.
#!/usr/bin/env python2





