$ ssh -f -N -v -t -L 5433:target_host:5432 user@jump_server
sudo apt-get install parted
Use parted to create partition:
Inside parted cli, follow these steps:
(parted) mklabel gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
(parted) unit GB
(parted) mkpart primary 0.0GB 3000GB
Format the filesystem we created, using mkfs and try to mount it to mount point:
mount /dev/sdb1 /tes
Add your mount point and swap permanently, so they will automatically mounted when you reboot.
$ sudo vim /etc/fstab
/swapfile swap swap sw 0 0
/dev/sdb1 /test1 ext3 defaults 0 0
/dev/sdb2 /test2 ext3 defaults 0 0
/dev/sdb3 /test3 ext3 defaults 0 0
This is a quick guide will show you how to open ssh tunnel to ssh into your target server that can only be accessed from jump server. So this is how to do it:
ssh -v -t -L 10443:localhost:20443 <jump_server> ssh -t -L 20443:localhost:443 user@<target_server>
- jump_server is the host that accessible from you and the only host that can access target_server
- target_server is the host that you want to access that only can be accessed from jump _server or bastion if you’re using AWS
- 10443 is the forwarded port that you can access to SSH to target_server
So, here is the example:
ssh -v -t -L 10443:localhost:20443 123.456.1.1 ssh -t -L 20443:localhost:443 firstname.lastname@example.org
- 123.456.1.1 is my jump_server that I can only access to access target_server
- 10.1.1.1 is the target_server
And try it out, see the magic for yourself! after the last command above executed, you will inside your target_server and 10443 port is open from your localhost.
If you want to just have your SSH session running in background and you want to SSH it by yourself, just try this command:
ssh -f -N -v -t -L 10443:localhost:20443 123.456.1.1 ssh -t -L 20443:localhost:443 email@example.com
if you want to remove the logs (disable verbose mode) when you logging in, just remove the “-v”
SSH to localhost with port 10443, to access your target_server
$ ssh localhost 10443
If your VPN client office using forticlient, you might want to run your VPN client with only command line, so you don’t have to see the small window just for connect your servers from home. With this bash script you can run your forclient VPN client only with CLI. GUI is for loosers.
Install expect first if you’re using ubuntu.
$ sudo apt-get install expect
Then copy this script below and save it. Inside the script there are some variables like username, password, host, port, that you need to fill.
# Forticlient SSL VPN Client launching script utilizing expect.
# VPN Credentials
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
if [ -z "$FORTICLIENT_PATH" ]; then
FORTICLIENT_PATH=`uname -r | grep -q 64 && echo $(locate forticlientsslvpn_cli | grep 64bit) || echo $(locate forticlientsslvpn_cli | grep 32bit)`
if [ ! -f $FORTICLIENT_PATH ]; then
echo "Tried to locate Forticlient SSL VPN Cli binary, but failed."
echo "Specify it at variable FORTCLIENT_PATH"
echo "Located Forticlient VPN Client at: $FORTICLIENT_PATH"
echo "Killing previous instances of Forticlient SSL VPN client..."
killall -9 $(basename $FORTICLIENT_PATH) 2> /dev/null
cat << EOF > /tmp/expect
set timeout -1
spawn $FORTICLIENT_PATH --server $VPN_HOST --vpnuser $VPN_USER --keepalive
expect "Password for VPN:"
send -- "$VPN_PASS"
send -- "\r"
expect "Would you like to connect to this server? (Y/N)"
send -- "Y"
send -- "\r"
expect "Clean up..."
chmod 500 /tmp/expect
/usr/bin/expect -f /tmp/expect
rm -f /tmp/expect
After you saved the script, let’s try to run it with sudo mode:
$ sudo vpn.sh &
These two commands will enable and disable your init script/service in system startup in Ubuntu 14.04:
Enable/add your service in startup
$ sudo update-rc.d docker defaults
Disable/remove service from startup
$ sudo update-rc.d -f docker remove
This is how to play your favorite music with command line, no UI bullshit
$ sudo apt-get install mpg321
$ cd ~/Music/
~/Music$ mpg321 Pink Floyd - Comfortably Numb.mp3
These command lines show you how to get your current public IP address just from terminal, just follow one of these way to get yours:
$ curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
Or, the shorter one:
$ curl ipinfo.io/ip
Sometimes it sucks when you listen to music on youtube with very limited sound level after your volume level has reached maximum and you’re using piece of shit earphone. Just go with this command to extend the limitation sound level, it works on ubuntu 14.04:
$ pactl -- set-sink-volume 0 150%
be careful with maximum sounds, can be dangerous for your ears.
To connect host with specific key
$ ssh user@host -i mykey.pem