To set up an SSH tunnel using local port forwarding in terminal
- Open a terminal window. On Mac OS X, choose Applications > Utilities > Terminal. On other Linux distributions, terminal is typically found at Applications > Accessories > Terminal.
 - Type the following command to open an SSH tunnel on your local machine. This command accesses the ResourceManager web interface by forwarding traffic on local port 8157 (a randomly chosen, unused local port) to port 8088 on the master node's local web server. In the command, replace
~/mykeypair.pemwith the location and file name of your.pemfile and replaceec2-###-##-##-###.compute-1.amazonaws.comwith the master public DNS name of your cluster.ssh -i~/mykeypair.pem-N -L8157:ec2-###-##-##-###.compute-1.amazonaws.com:8088 hadoop@ec2-###-##-##-###.compute-1.amazonaws.comAfter you issue this command, the terminal remains open and does not return a response.Note -Lsignifies the use of local port forwarding which allows you to specify a local port used to forward data to the identified remote port on the master node's local web server. - To open the ResourceManager web interface in your browser, type:
http://localhost:in the address bar.8157/ - When you are done working with the web interfaces on the master node, close the terminal windows.
 
from : https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-ssh-tunnel-local.html