Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Computer Resources
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IMGW
Computer Resources
Commits
0b696707
Commit
0b696707
authored
4 years ago
by
Michael Blaschek
Browse files
Options
Downloads
Patches
Plain Diff
fixed port forwarding
parent
b81fb2a7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SSH-VPN-VNC/connect2jet
+15
-11
15 additions, 11 deletions
SSH-VPN-VNC/connect2jet
with
15 additions
and
11 deletions
SSH-VPN-VNC/connect2jet
+
15
−
11
View file @
0b696707
...
@@ -11,21 +11,24 @@ help() {
...
@@ -11,21 +11,24 @@ help() {
cat
<<
EOF
cat
<<
EOF
$0
-g [gateway] -p [port] -r [remote-port] user@remote
$0
-g [gateway] -p [port] -r [remote-port] user@remote
Options:
Options:
-h Help
-g [gateway] gateway server, e.g. user@login.univie.ac.at
-g [gateway] gateway server, e.g. user@login.univie.ac.at
-p [port] port to forward from jet to local, e.g. VNC port
-p [port] port to forward from jet to local, e.g. VNC port
-r [port] remote port if not the same as port
-r [port] remote port if not the same as port
-d debug
Example:
Example:
$0
-g [U:Account-Username]@login.univie.ac.at [Jet-Username]@jet01.img.univie.ac.at
$0
-g [U:Account-Username]@login.univie.ac.at [Jet-Username]@jet01.img.univie.ac.at
EOF
EOF
}
}
debug
=
''
while
getopts
"g:p:r:h"
flag
;
do
while
getopts
"g:p:r:h
d
"
flag
;
do
case
"
${
flag
}
"
in
case
"
${
flag
}
"
in
g
)
gateway
=
${
OPTARG
}
;;
g
)
gateway
=
${
OPTARG
}
;;
p
)
port
=
${
OPTARG
}
;;
p
)
port
=
${
OPTARG
}
;;
r
)
rport
=
${
OPTARG
}
;;
r
)
rport
=
${
OPTARG
}
;;
d
)
debug
=
'-v'
;;
h
|
*
)
h
|
*
)
help
help
exit
0
exit
0
...
@@ -80,20 +83,21 @@ if [ -n "${gateway}" ]; then
...
@@ -80,20 +83,21 @@ if [ -n "${gateway}" ]; then
fi
fi
if
[
-n
"
${
port
}
"
]
;
then
if
[
-n
"
${
port
}
"
]
;
then
echo
"Using gateway:
$gateway
to
$remote
"
echo
"Using gateway:
$gateway
to
$remote
"
echo
"Port Forwarding via the gateway: "
midport
=
$((
$RANDOM
%
1000
+
20000
))
# 20000 - 21000
ssh
-L
${
port
}
:localhost:
${
port
}
-t
$gateway
ssh
-L
${
port
}
:
${
gateway
}
:
${
rport
}
${
remote
}
echo
"Port Forwarding via the gateway:
$port
:
$midport
:
$rport
"
echo
"
$(
date
)
| ssh -L
$port
:localhost:12345 -t
$gateway
'ssh -L 12345:
${
gateway
}
:
${
rport
}
${
remote
}
'"
>>
.
${
script
/.sh/.log
}
ssh
$debug
-L
${
port
}
:localhost:
${
midport
}
-t
$gateway
ssh
-L
${
midport
}
:localhost:
${
rport
}
${
remote
}
echo
"
$(
date
)
| ssh -L
${
port
}
:localhost:
${
midport
}
-t
$gateway
'ssh -L
${
midport
}
:localhost:
${
rport
}
${
remote
}
'"
>>
.
${
script
}
.log
else
else
echo
"Using gateway:
$gateway
to
$remote
"
echo
"Using gateway:
$gateway
to
$remote
"
ssh
$command
-t
$gateway
ssh
${
command
}
${
remote
}
ssh
$debug
$command
-t
$gateway
ssh
${
command
}
${
remote
}
echo
"
$(
date
)
| ssh
$command
-t
$gateway
'ssh
${
command
}
${
remote
}
'"
>>
.
${
script
/.sh/
.log
}
echo
"
$(
date
)
| ssh
$command
-t
$gateway
'ssh
${
command
}
${
remote
}
'"
>>
.
${
script
}
.log
fi
fi
else
else
if
[
!
$remote_status
]
;
then
if
[
!
$remote_status
]
;
then
echo
"Could fail if not: [user]@[server]"
echo
"Could fail if not: [user]@[server]"
fi
fi
echo
"Direct connection to:
${
remote
}
"
echo
"Direct connection to:
${
remote
}
"
ssh
${
command
}
${
remote
}
ssh
$debug
${
command
}
${
remote
}
echo
"
$(
date
)
| ssh
${
command
}
${
remote
}
"
>>
.
${
script
/.sh/
.log
}
echo
"
$(
date
)
| ssh
${
command
}
${
remote
}
"
>>
.
${
script
}
.log
fi
fi
echo
"Command Log in .
${
script
/.sh/
.log
}
"
echo
"Command Log in .
${
script
}
.log"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment