Using Screen / Linux

Create a session:

  • screen -S [sessionname]

Create a new interactive shell:

  • press ‘Ctrl-a + / Ctrl + c’

Switch betwwen screens:

  • press ‘Ctrl-a #’
    • # = Number of screen(1,2,3 etc)

Switch to next screen:

  • press ‘Ctrl-a + / Ctrl + n’

Switch to previous screen:

  • press ‘Ctrl-a + / Ctrl + p’

Resume a session that you started in a different location:

  • screen -d -R [sessionname]

SSH Authentication

  • Generate key pair

    • Linux: # ssh-keygen -t rsa
    • Putty: puttygen.exe
  • Load the private key in the PuTTY profile

  • Copy the public key to ~/.ssh/authorized_keys

  • Change permissions on folders

    • chmod 700 ~/.ssh
    • chmod 600 ~/.ssh/authorized_keys
  • Change owner on folder

    • Chown $USER:$USER ~/.ssh -R
  • Verify that folders aren’t group/world writeable

    • chmod go-w $HOME $HOME/.ssh $HOME/.ssh/authorized_keys
  • Edit sshd_config

    • # nano /etc/ssd_config
    • Make sure that a line says ‘AuthorizedKeysFile %h/.ssh/authorized_keys’
  • Restart SSH

    • # service ssh restart

Linux tips :: Various

Custom prompt

$ export PS1=”[\d \t \u@\h:\w]$”

2015-10-28 09_35_45-caab@wrksedfsh_ ~

Logging #1

Use Putty to log commands. Can be handy for documentation

  • Change Settings… –> Session –> Logging
    • Session logging –> Printable output

PuTTY Reconfiguration

Logging #2

Turn on continuous logging

export PROMPT_COMMAND='if [ "$(id -u)" -ne 0 ]; then echo "$(date "+%Y-%m-%d.%H:%M:%S") $(pwd) $(history 1)" >> ~/.logs/bash-history-$(date "+%Y-%m-%d").log; fi'

 

Then, to find a specific command or text string is as easy as

# grep -h nmap ~/.logs/bash-history-2016-06*