SCP к экземпляру EC2 не работает, но SSH работает
Я пытаюсь передать файл jar в экземпляр EC2, на котором размещена служба, над которой я работаю. Я могу без проблем подключиться к этому экземпляру EC2 по ssh. Когда я пытаюсь удалить файл с помощью следующей команды:
scp -vvv foo.jar instance-id:/tmp/
Мне предлагается ввести пароль, а после аутентификации я получаю следующий вывод:
debug1: Authentication succeeded (password).
Authenticated to <instance id> (via proxy).
...
debug1: Entering interactive session.
debug1: pledge: filesystem full
...
debug1: Sending command: scp -v -t /tmp/
debug2: channel 0: request exec confirm 1
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel 0: rcvd adjust 2097152
debug2: channel_input_status_confirm: type 99 id 0
debug2: exec request accepted on channel 0
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug2: channel 0: rcvd eow
debug2: chan_shutdown_read: channel 0: (i0 o0 sock -1 wfd 3 efd 7 [write])
debug2: channel 0: input open -> closed
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug2: channel 0: obuf empty
debug2: chan_shutdown_write: channel 0: (i3 o1 sock -1 wfd 6 efd 7 [write])
debug2: channel 0: output drain -> closed
debug2: channel 0: rcvd close
debug3: channel 0: will not send data after close
debug2: channel 0: almost dead
debug2: channel 0: gc: notify user
debug2: channel 0: gc: user detached
debug2: channel 0: send close
debug3: send packet: type 97
lost connection
debug2: channel 0: is dead
debug2: channel 0: garbage collecting
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
#0 client-session (t4 r0 i3/0 o3/0 e[write]/0 fd -1/-1/7 sock -1 cc -1)
debug3: send packet: type 1
debug1: fd 0 clearing O_NONBLOCK
debug3: fd 1 is not O_NONBLOCK
Transferred: sent 2752, received 2780 bytes, in 0.3 seconds
Bytes per second: sent 9360.6, received 9455.8
debug1: Exit status 1
журналы ssm-агента
2022-11-17 22:08:20 INFO inter process communication started at /var/lib/amazon/ssm/<instance id>/channels/<channel>
2022-11-17 22:08:20 INFO Running plugin Port Port
2022-11-17 22:08:20 INFO Setting up datachannel for session: <channel>, requestId: 50dfe339-7d47-41e4-9cd2-18eb4020e83e, clientId:
2022-11-17 22:08:20 INFO Opening websocket connection to: wss://ssmmessages.us-east-1.amazonaws.com/v1/data-channel/<channel>?role=publish_subscribe
2022-11-17 22:08:20 INFO Successfully opened websocket connection to: wss://ssmmessages.us-east-1.amazonaws.com/v1/data-channel/<channel>?role=publish_subscribe
2022-11-17 22:08:20 INFO Starting websocket pinger
2022-11-17 22:08:20 INFO Starting websocket listener
2022-11-17 22:08:20 INFO Initiating Handshake
2022-11-17 22:08:20 INFO Client side session manager plugin version is: 1.2.398.0
2022-11-17 22:08:20 INFO Handshake successfully completed.
2022-11-17 22:08:20 INFO Plugin Port started
2022-11-17 22:08:28 INFO TCP Connection was closed.
2022-11-17 22:08:28 INFO Closing datachannel with channel Id <channel>
2022-11-17 22:08:28 INFO Closing websocket channel connection to: wss://ssmmessages.us-east-1.amazonaws.com/v1/data-channel/<channel>?role=publish_subscribe
2022-11-17 22:08:28 INFO Ending websocket pinger
2022-11-17 22:08:28 INFO Ending the channel listening routine since the channel is closed
2022-11-17 22:08:28 INFO Ending websocket listener
2022-11-17 22:08:28 INFO Successfully closed websocket connection to: 67.220.242.9:443
2022-11-17 22:08:28 INFO Sending plugin Port completion message
2022-11-17 22:08:28 INFO document execution complete
2022-11-17 22:08:28 INFO sending document complete response...
2022-11-17 22:08:28 INFO stopping ipc worker...
2022-11-17 22:08:28 INFO requested shutdown, prepare to stop messaging
2022-11-17 22:08:28 INFO channel /var/lib/amazon/ssm/<instance id>/channels/<channel> requested close
2022-11-17 22:08:28 INFO worker listener stopped on path: /var/lib/amazon/ssm/<instance id>/channels/<channel>
2022-11-17 22:08:28 INFO channel /var/lib/amazon/ssm/<instance id>/channels/<channel> closed
2022-11-17 22:08:28 INFO ipc channel closed, stop messaging worker
2022-11-17 22:08:28 INFO requested terminate messaging worker, destroying the channel
2022-11-17 22:08:28 INFO Session worker closed
2022-11-17 22:08:28 INFO channel /var/lib/amazon/ssm/<instance id>/channels/<channel> requested close
2022-11-17 22:08:28 INFO Closed the file watcher listener thread
2022-11-17 22:08:28 INFO master listener stopped on path: /var/lib/amazon/ssm/<instance id>/channels/<channel>
2022-11-17 22:08:28 INFO sending reply for plugin update: Port
2022-11-17 22:08:28 INFO Done
2022-11-17 22:08:28 INFO sending document: <channel> complete response
2022-11-17 22:08:28 INFO received plugin: Port result from Processor
2022-11-17 22:08:28 INFO session: <channel> complete
2022-11-17 22:08:28 INFO received reply for SessionResult <channel> with message id ea77f702-1628-46ad-b94e-6b7d7f6998dc
Насколько я могу судить, я успешно подключаюсь к хосту. Похоже, передача файлов после этого сразу прекращается. scp терпит неудачу в обоих направлениях: я не могу перейти с удаленного на локальный или с локального на удаленный. В журналах ssm я заметил, что рукопожатие завершается успешно, а затем TCP-соединение немедленно закрывается. Я немного покопался в подобных вопросах, и ответившие сказали, что это может указывать на проблемы с оболочкой. Я просмотрел свой zshrc и не нашел строк, которые могли бы нарушить работу scp.