Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- function ssh_tunnel() {
- echo "Starting jump-machine-production tunnel on 127.0.0.1:2222 ....."
- ssh -o ExitOnForwardFailure=yes -o ServerAliveInterval=30 -NnT -L 127.0.0.1:2222:remote-production-machine:6379 jump-machine-production
- }
- function close_ssh_tunnel() {
- echo "Ending tunnel session on 127.0.0.1:2222"
- kill `ps -ax | grep "ssh" | grep "remote-production-machine" | cut -d ' ' -f 1`
- }
- ssh_tunnel &
- #the below line registers function close_ssh_tunnel to be called during script finish.
- #This will be called irrespective of script success or failure.
- trap close_ssh_tunnel EXIT
- (
- echo "DEL keyToBeDeleted"
- echo "exit"
- ) | telnet 127.0.0.1 2222
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement