This post will be kinda a notepad for different useful SSH tips and tricks.

Organize access to multiple hosts with RSA/DSA keys

If, on example, you have multiple private keys that is used to connect to multiple servers via SSH, instead of using construction like

ssh -i <key_file> user@server.com

you can simply create configuration file .ssh/config and organize all connections and use them after in a more simplified way:

Host short_host_name host.domain.com
    HostName host.domain.com
    IndentityFile ~/.ssh/host_domain_com_rsa
    User remote_username

Host another_short_name dummy.sample.net
	HostName dummy.sample.net
    IdentityFile ~/.ssh/dummy_sample_net_dsa
    User dummy_user

Connections can be simply established as ssh short_host_name and that's all!

Convert .ppk key to OpenSSH key format in Linux

If you have .ppk private key generated on Windows with puttygen and you need to get private key that can be used under Linux then follow these steps:

  1. Install PuTTY tools
    • Ubuntu: sudo apt install putty-tools
    • Debian: apt-get install putty-tools
    • RPM based: yum install putty
    • Gentoo: emerge putty
    • Archlinux: sudo pacman -S putty
  2. To generate private key:
puttygen id_dsa.ppk -O private-openssh -o id_dsa

To generate public key:

puttygen id_dsa.ppk -O public-openssh -o id_dsa.pub

Move these keys to ~/.ssh and set correct permissions:

mkdir -p ~/.ssh
mv -i ~/id_dsa* ~/.ssh
chmod 600 ~/.ssh/id_dsa
chmod 666 ~/.ssh/id_dsa.pub