File tree Expand file tree Collapse file tree 6 files changed +151
-2
lines changed Expand file tree Collapse file tree 6 files changed +151
-2
lines changed Original file line number Diff line number Diff line change
1
+ CHISEL_LOCAL_PORT=${CHISEL_LOCAL_PORT:- 5022}
2
+ CHISEL_REMOTE_PORT=${CHISEL_REMOTE_PORT:- 2022}
Original file line number Diff line number Diff line change
1
+ # Ignore client
2
+ chisel
3
+
4
+ # Ignore things that are done on a per-instance basis
5
+ id_rsa.pub
6
+ ssh_host_rsa_key
7
+ ssh_host_rsa_key.pub
Original file line number Diff line number Diff line change 54
54
(2022 in this case) is fixed. You can run multiple chisel clients simultaneously
55
55
by choosing a different local port (5022 in this case).
56
56
57
- 7 . Use SSH to login in the container
57
+ 7 . Add entry to ~ /.ssh/config (optional)
58
+
59
+ You can add an entry to your ssh config to make ssh'ing to chisel easier.
60
+ NOTE: the config file is position sensitive, so if you have a ` Host * `
61
+ entry in your file you need to add this before the ` Host * ` entry.
62
+
63
+ ```
64
+ Host chisel
65
+ ForwardAgent yes
66
+ HostName localhost
67
+ Port 5022
68
+ User vcap
69
+ Compression yes
70
+ ```
71
+
72
+ This entry will allow you to simply `ssh chisel` to connect.
73
+
74
+ 8. Use SSH to login in the container
58
75
59
76
Use standard SSH applications to connect to the SSH daemon in the container.
60
77
The user name to connect as is `vcap`. The SSH utiliites will use your private
64
81
`-i` switch. You must have uploaded the corresponding public key in step 3
65
82
above, for this to work.
66
83
84
+ If you added an entry to ~/.ssh/config:
85
+
86
+ ```
87
+ ssh chisel
88
+ ```
89
+
90
+ otherwise:
91
+
67
92
```
68
93
ssh vcap@localhost -p 5022
69
94
```
70
95
71
- 8 . Perform local port forwarding
96
+ 9 . Perform local port forwarding
72
97
73
98
You can also use SSH to perform local port forwarding.
74
99
75
100
For example, you can use this command to create a local port 6632 that
76
101
forwards all TCP traffic to your Postgres database (port 5432) instance
77
102
that is only accessible from Cloud Foundry applications.
78
103
104
+ If you added an entry to ~/.ssh/config:
105
+
106
+ ```
107
+ ssh -L 6632:myapp-db.example.com:5432 chisel
108
+ ```
109
+
110
+ otherwise:
111
+
79
112
```
80
113
ssh -L 6632:myapp-db.example.com:5432 vcap@localhost -p 5022
81
114
```
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ set -e
4
+
5
+ cd ` dirname $0 `
6
+
7
+ for f in ` egrep -v ' ^#' .gitignore` ; do
8
+ if echo $f | egrep -q ' ^/|\.\.' ; then
9
+ echo " Ignoring dangerous .gitignore entry $f "
10
+ else
11
+ echo Removing $f
12
+ rm -f $f
13
+ fi
14
+ done
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ set -e # exit on error
4
+
5
+ cd ` dirname $0 `
6
+ source .default.sh
7
+
8
+ appname=" cf-ssh-chisel-$USER "
9
+
10
+ # Generate a key to identify the server (if one doesn't already exist)
11
+ # TODO: put all generated files (this and id_rsa.pub) into a single directory
12
+ if [ ! -r ssh_host_rsa_key ]; then
13
+ ssh-keygen -t rsa -f ssh_host_rsa_key -N ' ' -C " chisel-ssh identity for $appname "
14
+ echo ' [localhost]:$CHISEL_LOCAL_PORT' ` cat ssh_host_rsa_key.pub` >> ~ /.ssh/known_hosts
15
+ fi
16
+
17
+ if [ ! -r id_rsa.pub ]; then
18
+ cp ~ /.ssh/id_rsa.pub .
19
+ fi
20
+
21
+ if ! grep -q ' Host chisel' ~ /.ssh/config; then
22
+ cat << _EOF_
23
+
24
+ You might want to add this entry to ~/.ssh/config. Note that the config file is
25
+ position-sensitive, so this needs to be added before the 'Host *' entry if you
26
+ have one.
27
+
28
+ Host chisel
29
+ ForwardAgent yes
30
+ HostName localhost
31
+ Port $CHISEL_LOCAL_PORT
32
+ User vcap
33
+ Compression yes
34
+ _EOF_
35
+ fi
36
+
37
+ cf push -t 180 $appname & # -t: maximum number of seconds to wait for app to start
38
+
39
+ export GOPATH=$( echo ${PWD% src/ github.com/ jpillora/ chisel} )
40
+ go build
41
+
42
+ wait
43
+
44
+ ./tunnel
45
+
46
+ # vi: expandtab sw=2 ts=2
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ set -e # exit on error
4
+
5
+ cd ` dirname $0 `
6
+
7
+ appname=" cf-ssh-chisel-$USER "
8
+ echo " Starting $appname forwarding local port ${CHISEL_LOCAL_PORT:= 5022} to remote port ${CHISEL_REMOTE_PORT:= 2022} "
9
+
10
+ echo " Checking if $appname is running"
11
+ cf app $appname > /dev/null # Make sure app is there
12
+
13
+ if ! cf app $appname | grep -q running; then
14
+ echo " ERROR: $appname is not running"
15
+ exit 1
16
+ fi
17
+
18
+ echo " Obtaining url for $appname "
19
+ url=` cf app $appname | egrep ' routes|urls' | awk ' {print $2}' `
20
+
21
+ # Sanity-check the URL. This is kinda important because the chisel client
22
+ # doesn't complain if it can't connect. :(
23
+ echo " $url " | grep " $appname " | grep -q predix.io || { echo " URL doesn't look sane: $url " ; exit 2; }
24
+
25
+ # If there's an existing client running, kill it
26
+ client_pids=` ps auxww | grep ./chisel | grep ${CHISEL_LOCAL_PORT} :${CHISEL_REMOTE_PORT} | grep -v grep | awk ' {print $2}' `
27
+ if [ -n " $client_pids " ]; then
28
+ kill $client_pids
29
+ fi
30
+
31
+ echo " Starting client, connecting to $url "
32
+ cmd=" ./chisel client --keepalive 10s https://$url ${CHISEL_LOCAL_PORT} :${CHISEL_REMOTE_PORT} "
33
+ echo " Running in background: $cmd "
34
+ $cmd > /dev/null &
35
+
36
+ cat << _EOF_
37
+ You can now connect via
38
+
39
+ ssh vcap@localhost -p ${CHISEL_LOCAL_PORT}
40
+
41
+ or **IF** you added an entry to ~/.ssh/config:
42
+
43
+ ssh chisel
44
+
45
+ _EOF_
46
+
47
+ # vi: expandtab sw=2 ts=2
You can’t perform that action at this time.
0 commit comments