Monday, October 29, 2018

Linux SSH tunneling using certificate

To connect via ssh on remote host and activate tuneling using a certificate, you need a pem certificate. if you have ppk certificate you can convert.

Do it with Putty.
  • Linux: with your package manager, install PuTTY (or the more minimal PuTTY-tools):
    • Ubuntu sudo apt-get install putty-tools
    • Debian-like apt-get install putty-tools
    • RPM based dnf install putty
    • Gentoo emerge putty
    • Archlinux sudo pacman -S putty
    • etc.
  • OS X: Install Homebrew, then run brew install putty
Place your keys in some directory, e.g. your home folder. Now convert the PPK keys to SSH keypairs:cache search
To generate the private key:
cd ~
puttygen id_dsa.ppk -O private-openssh -o id_dsa
and to generate the public key:
puttygen id_dsa.ppk -O public-openssh -o id_dsa.pub
Move these keys to ~/.ssh and make sure the permissions are set to private for your private key:
mkdir -p ~/.ssh
mv -i ~/id_dsa* ~/.ssh
chmod 600 ~/.ssh/id_dsa
chmod 666 ~/.ssh/id_dsa.pub

to connect via SSH  tunnel use:

ssh -i GATEWAY_KEY.pem ubuntu@GATEWAY_IP -L 1122:SERVER_PRIVATE_IP:22

where GATEWAY_KEY.pem is the certificate and ubuntu is the user tu use. 1122 is the destination port (tunneling port) and 22 is the source port

example:
ssh -i mdg_rsa.pem opc@130.61.63.164 -L 1521:10.0.0.5:1521


No comments:

Post a Comment