netsec-ethz / scion-apps

Public repository for SCION applications
Apache License 2.0
20 stars 43 forks source link

ssh client and server is unusable: Error trying to change window size #256

Open MatthewCroughan opened 4 months ago

MatthewCroughan commented 4 months ago

When using the scion ssh client and server, the client is able to connect and it is almost fully functional, however the client tries to connect and believes the server failed to spawn the shell. But the server does successfully spawn the shell, and throws an error failing to set the window size via /dev/ptmx. It should also be noted the server not only successfully spawns bash, it also creates a /dev/pts/2 node when the client connection is made:

 |         \-+= 240249 root sudo -E scion-ssh-server -oPort=2200 -oAuthorizedKeysFile=/home/ma
 |           \-+= 240252 root sudo -E scion-ssh-server -oPort=2200 -oAuthorizedKeysFile=/home/
 |             \-+= 240253 root scion-ssh-server -oPort=2200 -oAuthorizedKeysFile=/home/matthe
 |               \--= 245473 matthew bash 
Client
scion-ssh-client -p 2200 17-ffaa:1:xxxx,127.0.0.1 -i ~/.ssh/id_rsa
2024/07/01 14:24:38 Error while updating config: unknown config option: ForwardX11 <invalid reflect.Value>
2024/07/01 14:24:38 Error while updating config: unknown config option: GlobalKnownHostsFile <invalid reflect.Value>
2024/07/01 14:24:38 Error while updating config: unknown config option: AddressFamily <invalid reflect.Value>
2024/07/01 14:24:38 Error while updating config: unknown config option: Host <invalid reflect.Value>
2024/07/01 14:24:38 Error while updating config: unknown config option: VerifyHostKeyDNS <invalid reflect.Value>
2024/07/01 14:24:38 Error while updating config: unknown config option: Match <invalid reflect.Value>
2024/07/01 14:24:38 Error while updating config: unknown config option: HostName <invalid reflect.Value>
2024/07/01 14:24:38 Error while updating config: unknown config option: Host <invalid reflect.Value>
2024/07/01 14:24:38 Error while updating config: unknown config option: Host <invalid reflect.Value>
2024/07/01 14:24:38 Error while updating config: unknown config option: Host <invalid reflect.Value>
2024/07/01 14:24:38 Error while updating config: unknown config option: ControlPersist <invalid reflect.Value>
2024/07/01 14:24:38 Error while updating config: unknown config option: ControlPath <invalid reflect.Value>
2024/07/01 14:24:38 Error while updating config: unknown config option: ControlMaster <invalid reflect.Value>
DBUG[07-01|14:24:38] Loaded private key                       IdentityFile=/home/matthew/.ssh/id_rsa
DBUG[07-01|14:24:38] Error loading private key, skipped.      IdentityFile=~/.ssh/identity err="open /home/matthew/.ssh/identity: no such file or directory"
DBUG[07-01|14:24:38] Loaded private key                       IdentityFile=~/.ssh/id_rsa
DBUG[07-01|14:24:38] Error loading private key, skipped.      IdentityFile=~/.ssh/id_dsa err="open /home/matthew/.ssh/id_dsa: no such file or directory"
DBUG[07-01|14:24:38] Error loading private key, skipped.      IdentityFile=~/.ssh/id_ecdsa err="open /home/matthew/.ssh/id_ecdsa: no such file or directory"
DBUG[07-01|14:24:38] Loaded private key                       IdentityFile=~/.ssh/id_ed25519
DBUG[07-01|14:24:38] Configuring password auth 
DBUG[07-01|14:24:39] Checking new host signature host         remote=17-ffaa:1:xxxx,127.0.0.1:2200
2024/07/01 14:24:39 Error starting shell: ssh: could not start shell
panic: Error starting shell: ssh: could not start shell

goroutine 1 [running]:
log.Panicf({0xeb3f97?, 0xffeed8?}, {0xc00059ff28?, 0xff3358?, 0x2?})
    log/log.go:439 +0x65
main.main()
    github.com/netsec-ethz/scion-apps/ssh/client/main.go:189 +0x49d
Server
$ sudo -E scion-ssh-server -oPort=2200 -oAuthorizedKeysFile=/home/matthew/authkeys --config-file /home/matthew/sshd_config 
[sudo] password for matthew: 
DBUG[07-01|13:24:13] Starting SCION SSH server... 
DBUG[07-01|13:24:13] Currently, ListenAddress.Port is ignored (only value from config taken) 
DBUG[07-01|13:24:13] Starting to wait for connections 
DBUG[07-01|13:24:39] Handling new connection 
DBUG[07-01|13:24:39] New SSH connection                       remoteAddress=17-ffaa:1:xxx,127.0.0.1:32790 clientVersion="[83 83 72 45 50 46 48 45 71 111]"
DBUG[07-01|13:24:39] Creating pty... 
DBUG[07-01|13:24:39] Error trying to change window size       error="errno 0" w=191 h=47
EROR[07-01|13:25:09] Could not close connection               error=EOF
DBUG[07-01|13:25:09] Connection to pty copy ended             error=nil
DBUG[07-01|13:25:09] Pty to connection copy ended             error="read /dev/ptmx: input/output error"
EROR[07-01|13:25:09] Error waiting for bash to end            error="signal: killed"
EROR[07-01|13:25:09] Error sending exit status                error=EOF
DBUG[07-01|13:25:09] Session closed 

The code for size setting via ptmx is located in

https://github.com/netsec-ethz/scion-apps/blob/cb0dc365082788bcc896f0b55c4807b72c2ac338/ssh/server/ssh/sessionchannel.go#L245-L250

Things I've tried to no avail