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
I want to create a script that when I double click runs:
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 200.200.200.1
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.
Furthermore to what Jason said, another less elegant solution where you don't need to change the config and can enter other ssh parameters like -t and -Y:
ssh -tY user@server1 "ssh -tY user@server2; bash -s"