SSH Public Key Based Authentication

Motivation: I want to acces to my Bluehost server from my local computer, make some file copies ‘scp’ but from a script executed by Crontab, so I don’t want to introduce my password manually.
Solution:

  • Generate the key from your local machine (I don’t think it’s needed but, store the keys in ~/.ssh

    1
    
    ssh-keygen -t rsa
    ssh-keygen -t rsa
  • Copy the public key to your server:

    1
    
    scp .ssh/id_rsa.pub username@server_name_address:.ssh/authorized_keys2
    scp .ssh/id_rsa.pub username@server_name_address:.ssh/authorized_keys2

Source: ciberciti

VIM tab configuration

Motivation: I like to edit files using VIM. In my server (Bluehost) the default configuration makes my ‘tab’ to produce really width spaces and I want it to be the size of 4 spaces.
Solution: I edited a file .vimrc and I placed in my home directory in my server. The content of this file is the following:

1
2
3
4
5
set expandtab
set smartindent
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set smartindent
set tabstop=4
set softtabstop=4
set shiftwidth=4

Password Protect a Directory with .htaccess

Motivation: protect some directories from being accessed without authorisation.
Solution: using the .httaccess file. You just have to configure one and place it into the directory you want to protect. The code inside the file would look something like this:

1
2
3
4
AuthType Basic
AuthName "guest"
AuthUserFile "/home/user/.htpasswds/public_html/directory2storepass/passwd"
require valid-user
AuthType Basic
AuthName "guest"
AuthUserFile "/home/user/.htpasswds/public_html/directory2storepass/passwd"
require valid-user

Then you have to place the password in the directory you have chosen.
The source I’ve used.