Securing Ubuntu SSH

  1. Update the /etc/ssh/sshd_config file to have the following added:
    PermitRootLogin no
  2. Install fail2ban using the following command:
    sudo apt-get install fail2ban
  3. Create the file /etc/fail2ban/jail.d/jail-debian.local file to have the following:
     enabled = true
     port = ssh
     filter = sshd
     logpath = /var/log/auth.log
     maxretry = 6
     bantime = -1
  4. Restart the service using the following command:
    sudo service fail2ban restart

See Unbanning an IP

Using Scanner to Read a Text File

Reading a text file using java.util.Scanner in Java.

StringBuilder text = new StringBuilder();
try(Scanner scanner = new Scanner(new BufferedReader(new FileReader("<FILENAME>")))) {
    while(scanner.hasNext()) {
} catch (FileNotFoundException e) {


FILENAME The text file to read.