All posts by Mahmood

Set Up Time Synchronization on Ubuntu with ntpd

Though timesyncd is fine for most purposes, some applications that are very sensitive to even the slightest perturbations in time may be better served by ntpd, as it uses more sophisticated techniques to constantly and gradually keep the system time on track.

sudo timedatectl set-ntp no
sudo apt-get install ntp
sudo ntpq -p


Extra Repositories for Ubuntu Server 18.04

deb bionic universe multiverse
deb-src bionic universe multiverse

deb bionic universe
deb-src bionic universe
deb bionic-updates universe
deb-src bionic-updates universe

deb bionic multiverse
deb-src bionic multiverse
deb bionic-updates multiverse
deb-src bionic-updates multiverse

deb bionic-security universe
deb-src bionic-security universe
deb bionic-security multiverse
deb-src bionic-security multiverse


Spring Boot: Configuring a Main Class

Spring Boot 1.x

jar {
    baseName = 'interface'
    version = '0.0.1-SNAPSHOT'
    manifest {
        attributes 'Main-Class': 'net.pupli.sobhan.SobhanApplication'

Spring Boot 2.x

springBoot {
    mainClassName = 'org.baeldung.DemoApplication'


bootJar {
    mainClassName = 'org.baeldung.DemoApplication'
bootJar {
    manifest {
    attributes 'Start-Class': 'org.baeldung.DemoApplication'


Set Up SSH Keys on Ubuntu

Create the RSA Key Pair


Copy the Public Key to Ubuntu Server

cat ~/.ssh/ | ssh username@remote_host "mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys && chmod -R go= ~/.ssh && cat >> ~/.ssh/authorized_keys"

or Copying Public Key Manually

To display the content of your key, type this into your local computer:

cat ~/.ssh/

You will see the key’s content, which should look something like this:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCqql6MzstZYh1TmWWv11q5O3pISj2ZFl9HgH1JLknLLx44+tXfJ7mIrKNxOOwxIxvcBF8PXSYvobFYEZjGIVCEAjrUzLiIxbyCoxVyle7Q+bqgZ8SeeM8wzytsY+dVGcBxF6N4JS+zVk5eMcV385gG3Y6ON3EG112n6d+SMXY0OEBIcO6x+PnUSGHrSgpBgX7Ks1r7xqFa7heJLLt2wWwkARptX7udSq05paBhcpB0pHtA1Rfz3K2B+ZVIpSDfki9UVKzT8JUmwW6NNzSgxUfQHGwnW7kj4jp4AT0VZk3ADw497M2G/12N0PPB5CnhHf7ovgy6nL1ikrygTKRFmNZISvAcywB9GVqNAVE+ZHDSCuURNsAInVzgYo9xgJDW8wUw2o8U77+xiFxgI5QSZX3Iq7YLMgeksaO4rBJEa54k8m5wEiEE1nUhLuJ0X/vh2xPff6SQ1BL/zkOhvJCACK6Vb15mDOeCSq54Cr7kvS46itMosi/uS66+PujOO+xt/2FWYepz6ZlN70bRly57Q06J+ZJoc9FfBCbCyYH7U/ASsmY095ywPsBo1XQ9PqhnN1/YOorJ068foQDNVpm146mUpILVxmq41Cj55YKHEazXGsdBIbXWhcrRf4G2fJLRcGUr9q8/lERo9oxRm5JFX6TCmj6kmiFqv+Ow9gI0x8GvaQ== demo@test

make sure the ~/.ssh directory exists.This command will create the directory if necessary, or do nothing if it already exists:

mkdir -p ~/.ssh

Now, you can create or modify the authorized_keys file within this directory. You can add the contents of your file to the end of the authorized_keys file, creating it if necessary, using this command:

echo public_key_string >> ~/.ssh/authorized_keys

Finally, we’ll ensure that the ~/.ssh directory and authorized_keys file have the appropriate permissions set:

chmod -R go= ~/.ssh

Authenticate to Ubuntu Server Using SSH Keys

ssh username@remote_host

Disable Password Authentication on your Server

sudo nano /etc/ssh/sshd_config
PasswordAuthentication no
sudo systemctl restart ssh


Change the encryption cipher for server and client of OpenVPN Access Server

cd /usr/local/openvpn_as/scripts

View current cipher configuration keys

./sacli ConfigQuery | grep "cipher"

Set the cipher configuration key to the desired cipher:

./sacli --key "vpn.client.cipher" --value AES-128-CBC ConfigPut
./sacli --key "vpn.server.cipher" --value AES-128-CBC ConfigPut
./sacli start


Padding Strings with format method on Java

public static void main(String[] args) {
    Scanner sc = new Scanner(;
    String s1 =;
    int x = sc.nextInt();

    System.out.printf("%03d", x);

    System.out.printf("%03d", x);

private static void PadRight(String s)
    System.out.printf("%1$15s", s);

private static void PadLeft(String s)
    System.out.printf("%1$-15s", s);

15 represents the minimal width of the String




Hello          012