Skip to content

Commit 9ae5f1d

Browse files
committed
Merge branch 'master' into tr_graph
2 parents d6fc167 + 2b7ec0c commit 9ae5f1d

31 files changed

+2801
-58
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ sensorapp/sensorserver/sensorserver
4949
webapp/webapp
5050
tools/pathdb_dump/pathdb_dump
5151
netcat/netcat
52+
ssh/client/client
53+
ssh/server/server
5254
roughtime/timeclient/timeclient
5355
roughtime/timeserver/timeserver
5456

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.PHONY: all clean
22

33
ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
4-
SRCDIRS= helloworld sensorapp/sensorserver sensorapp/sensorfetcher camerapp/imageserver camerapp/imagefetcher bwtester/bwtestserver bwtester/bwtestclient webapp bat bat/example_server tools/pathdb_dump roughtime/timeserver roughtime/timeclient netcat
4+
SRCDIRS= helloworld sensorapp/sensorserver sensorapp/sensorfetcher camerapp/imageserver camerapp/imagefetcher bwtester/bwtestserver bwtester/bwtestclient webapp bat bat/example_server tools/pathdb_dump roughtime/timeserver roughtime/timeclient ssh/client ssh/server netcat
55
TARGETS = $(foreach D,$(SRCDIRS),$(D)/$(notdir $(D)))
66

77
all: $(TARGETS)

ssh/README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# SCION enabled SSH
2+
3+
SSH client and server running over SCION network.
4+
5+
# Installation
6+
7+
## Prerequisite
8+
9+
SCION infrastructure has to be installed and running. Instructions can be found [here](https://github.com/scionproto/scion)
10+
11+
Additional development library for PAM is needed:
12+
```
13+
sudo apt-get install libpam0g-dev
14+
```
15+
16+
# Running
17+
18+
To generate TLS connection certificates:
19+
```
20+
# These are valid for 365 days, so you'll have to renew them periodically
21+
# Client
22+
cd ~/.ssh
23+
openssl req -newkey rsa:2048 -nodes -keyout quic-conn-key.pem -x509 -days 365 -out quic-conn-certificate.pem
24+
-# Server
25+
cd /etc/ssh
26+
sudo openssl req -newkey rsa:2048 -nodes -keyout quic-conn-key.pem -x509 -days 365 -out quic-conn-certificate.pem
27+
```
28+
29+
You'll also need to create a client key (if you don't have one yet):
30+
```
31+
cd ~/.ssh
32+
ssh-keygen -t rsa -f id_rsa
33+
```
34+
35+
And create an authorized key file for the server with the public key (note that you'd usually place this in `/home/<user>/.ssh/authorized_keys` whereas `<user>` is the user on the server you want to gain access to, but make sure not to overwrite an existing file):
36+
```
37+
cd $GOPATH/src/github.com/netsec-ethz/scion-apps/ssh/server
38+
cp ~/.ssh/id_rsa.pub ./authorized_keys
39+
```
40+
41+
Running the server:
42+
```
43+
cd $GOPATH/src/github.com/netsec-ethz/scion-apps/ssh/server
44+
# If you are not root, you need to use sudo. You might also need the -E flag to preserve environment variables (like $SC)
45+
sudo -E ./server -oPort=2200 -oAuthorizedKeysFile=./authorized_keys
46+
# You might also want to disable password authentication for security reasons with -oPasswordAuthentication=no
47+
```
48+
49+
50+
Running the client:
51+
```
52+
cd $GOPATH/src/github.com/netsec-ethz/scion-apps/ssh/client
53+
./client -p 2200 1-11,[127.0.0.1] -oUser=username
54+
```
55+
56+
Using SCP (make sure you've done `chmod +x ./scp.sh` first):
57+
```
58+
cd $GOPATH/src/github.com/netsec-ethz/scion-apps/ssh/scp
59+
./scp.sh -P 2200 localFileToCopy.txt [1-11,[127.0.0.1]]:remoteTarget.txt
60+
```
61+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package clientconfig
2+
3+
// ClientConfig is a struct containing configuration for the client.
4+
type ClientConfig struct {
5+
User string `regex:".*"`
6+
HostAddress string `regex:"(?P<ia>\\d+-[\\d:A-Fa-f]+),\\[(?P<host>[^\\]]+)\\]"`
7+
Port string `regex:"0*([0-5]?\\d{0,4}|6([0-4]\\d{3}|5([0-4]\\d{2}|5([0-2]\\d|3[0-5]))))"`
8+
PasswordAuthentication string `regex:"(yes|no)"`
9+
PubkeyAuthentication string `regex:"(yes|no)"`
10+
StrictHostKeyChecking string `regex:"(yes|no|ask)"`
11+
IdentityFile []string `regex:".*"`
12+
LocalForward string `regex:".*"`
13+
RemoteForward string `regex:".*"`
14+
UserKnownHostsFile string `regex:".*"`
15+
ProxyCommand string `regex:".*"`
16+
QUICCertificatePath string `regex:".*"`
17+
QUICKeyPath string `regex:".*"`
18+
}
19+
20+
// Create creates a new ClientConfig with the default values.
21+
func Create() *ClientConfig {
22+
return &ClientConfig{
23+
User: "",
24+
HostAddress: "",
25+
Port: "22",
26+
PasswordAuthentication: "yes",
27+
PubkeyAuthentication: "yes",
28+
StrictHostKeyChecking: "ask",
29+
UserKnownHostsFile: "~/.ssh/known_hosts",
30+
IdentityFile: []string{
31+
"~/.ssh/id_ed25519",
32+
"~/.ssh/id_ecdsa",
33+
"~/.ssh/id_dsa",
34+
"~/.ssh/id_rsa",
35+
"~/.ssh/identity",
36+
},
37+
LocalForward: "",
38+
RemoteForward: "",
39+
ProxyCommand: "",
40+
QUICCertificatePath: "~/.ssh/quic-conn-certificate.pem",
41+
QUICKeyPath: "~/.ssh/quic-conn-key.pem",
42+
}
43+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
package clientconfig
2+
3+
import (
4+
"fmt"
5+
"strings"
6+
"testing"
7+
8+
"github.com/netsec-ethz/scion-apps/ssh/config"
9+
. "github.com/smartystreets/goconvey/convey"
10+
)
11+
12+
func TestDefaultConfig(t *testing.T) {
13+
Convey("Given an example SSH config file", t, func() {
14+
configString := `
15+
Host *
16+
ForwardAgent no
17+
ForwardX11 no
18+
ForwardX11Trusted yes
19+
RhostsRSAAuthentication no
20+
RSAAuthentication yes
21+
PasswordAuthentication no
22+
HostbasedAuthentication yes
23+
GSSAPIAuthentication no
24+
GSSAPIDelegateCredentials no
25+
GSSAPIKeyExchange no
26+
GSSAPITrustDNS no
27+
BatchMode no
28+
CheckHostIP yes
29+
AddressFamily any
30+
ConnectTimeout 0
31+
StrictHostKeyChecking no
32+
IdentityFile ~/.ssh/identity
33+
IdentityFile ~/.ssh/id_rsa
34+
IdentityFile ~/.ssh/id_dsa
35+
IdentityFile ~/.ssh/id_ecdsa
36+
IdentityFile ~/.ssh/id_ed25519
37+
Port 65535
38+
Protocol 2
39+
Cipher 3des
40+
Ciphers aes128-ctr,aes192-ctr,aes256-ctr$
41+
MACs hmac-md5,hmac-sha1,umac-64@openssh.$
42+
EscapeChar ~
43+
Tunnel no
44+
TunnelDevice any:any
45+
PermitLocalCommand no
46+
VisualHostKey no
47+
ProxyCommand ssh -q -W %h:%p gateway.exa$
48+
RekeyLimit 1G 1h
49+
SendEnv LANG LC_*
50+
HashKnownHosts yes
51+
GSSAPIAuthentication yes
52+
GSSAPIDelegateCredentials no
53+
`
54+
55+
Convey("The new values are read correctly", func() {
56+
conf := &ClientConfig{}
57+
config.UpdateFromReader(conf, strings.NewReader(configString))
58+
So(conf.HostAddress, ShouldEqual, "")
59+
So(conf.PasswordAuthentication, ShouldEqual, "no")
60+
So(conf.StrictHostKeyChecking, ShouldEqual, "no")
61+
So(conf.Port, ShouldEqual, "65535")
62+
So(conf.IdentityFile[len(conf.IdentityFile)-1], ShouldEqual, "~/.ssh/identity")
63+
So(conf.IdentityFile[len(conf.IdentityFile)-2], ShouldEqual, "~/.ssh/id_rsa")
64+
So(conf.IdentityFile[len(conf.IdentityFile)-3], ShouldEqual, "~/.ssh/id_dsa")
65+
So(conf.IdentityFile[len(conf.IdentityFile)-4], ShouldEqual, "~/.ssh/id_ecdsa")
66+
So(conf.IdentityFile[len(conf.IdentityFile)-5], ShouldEqual, "~/.ssh/id_ed25519")
67+
})
68+
69+
})
70+
}
71+
72+
func TestPortRegex(t *testing.T) {
73+
Convey("Given a default config file", t, func() {
74+
conf := &ClientConfig{}
75+
76+
Convey("Valid port numbers are accepted", func() {
77+
nums := []int{1, 2, 3, 10, 100, 1000, 10000, 45, 652, 3486, 43621, 6554, 66, 65535}
78+
for _, i := range nums {
79+
err := config.Set(conf, "Port", i)
80+
So(err, ShouldEqual, nil)
81+
So(conf.Port, ShouldEqual, fmt.Sprintf("%v", i))
82+
}
83+
})
84+
85+
Convey("Invalid port numbers are not accepted", func() {
86+
nums := []int{-1, 2, 3, 351000, 10064300, 455635, 65345632, 34845636, 6436554, 65536, 70000}
87+
for _, i := range nums {
88+
if i >= 0 && i <= 65535 {
89+
continue
90+
}
91+
initialPort := conf.Port
92+
err := config.Set(conf, "Port", i)
93+
So(err, ShouldNotEqual, nil)
94+
So(conf.Port, ShouldEqual, fmt.Sprintf("%v", initialPort))
95+
}
96+
})
97+
98+
})
99+
}

0 commit comments

Comments
 (0)