On a linux vm inside of an automated codebuild CI/CD Pipeline this command executes as expected:
scp -v -i /path/to/key ./scp_test.txt user@host:$target_dir
However, a similar ssh using the same credentials does not:
ssh -vvv -i /path/to/key user@host "touch ssh_test.txt $target_dir"
The issue does not seem to be with connecting (part of logs is debug1: Connection established), authenticating (scp works), or permissions (have ran this command from local machine with same credentials).
Some relevant ssh logs: Some Relevant failed ssh logs:
debug:1: Sending command: touch ssh_test.txt <target_dir>
debug:2: channel 0: request exec confirm 1
debug:3: send packet: type 98
debug:2: callback done
debug:2: channel 0: open confirm rwindow 0 rmax 32768
debug:2: channel 0: rcvd adjust 2097152
debug:3: receive packet: type 99
debug:2: channel_input_status_confirm: type 99 id 0
debug:2: exec request accepted on channel 0
debug:2: channel 0: read<=0 rfd 5 len 0
debug:2: channel 0: read failed
debug:2: channel 0: close_read