I want to create a script that when I double click runs:
- 'ssh -Y server1'
- WITHIN server1 run 'ssh -Y server2' (server2 not accessible outside)
- I now have the terminal prompt connected to server2 waiting to run commands
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
You can use SSH's
-W option to achieve this. From the manual:
-W host :port
Requests that standard input and output on the client be forwarded to host on port over the secure channel. Implies -N, -T, ExitOnForward-Failure and ClearAllForwardings. Works with Protocol version 2 only.
You can set this up in your
~/.ssh/config to simplify the process, like so:
Host Server1 Hostname 126.96.36.199 Port 2222 User you IdentityFile ~/.ssh/id_rsa Host Server2 Hostname 192.168.1.2 Port 3333 User you IdentityFile ~/.ssh/id_dsa # Hop to 2 Host Server2 ProxyCommand ssh -W %h:%p Server1
You then simply
ssh Server2 and—provided you have set up your authentication correctly—you will be logged in to Server2.