Jump to content
Калькуляторы

SSH скрипт для заливки конфига на S2962

 Всем добрый день.

 

Есть задача залить конфиг на 300+ через SSH скрипт. Но он почему-то зависает.

 

#!/bin/bash
iplist="SNR"


while read -r line
do
echo "Patching IP "$line""

sshpass -p "pass" ssh -T -o StrictHostKeyChecking=no user@$line < cmd.cfg

done < $iplist

 

 

Зависает сама команда: ssh -T user@switch.test < cmd.cfg

 

После ввода пароля, вывод зависает. В локах свича есть вход пользователя и все. Даже если в вводном файле всего одна команда, например who

Если же использую "ssh -T user@switch.test who", то все отрабатывается норм.

 

Что я делаю не так?

 

SoftWare Version 7.0.3.5(R0241.0531)

 

 

Заранее Спасибо

 

Edited by surgeon

Share this post


Link to post
Share on other sites

On 9/14/2022 at 4:31 PM, Pinkbyte said:

-vvv в ssh добавьте и выхлоп весь в файлы перенаправьте(&>/path/to/file) и смотрите

похоже свич не присылает запрос на ввод

 

Это ответ циски


 

debug3: Ignored env OLDPWD
debug2: channel 0: request shell confirm 1
debug3: send packet: type 98
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel 0: rcvd adjust 2097152
debug3: receive packet: type 99
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0
debug2: channel 0: read<=0 rfd 4 len 0
debug2: channel 0: read failed
debug2: channel 0: chan_shutdown_read (i0 o0 sock -1 wfd 4 efd 6 [write])
debug2: channel 0: input open -> drain
debug2: channel 0: ibuf empty
debug2: channel 0: send eof
debug3: send packet: type 96
debug2: channel 0: input drain -> closed

debug2: channel 0: rcvd ext data 53
stty: standard input: Inappropriate ioctl for device
debug2: channel 0: written 53 to efd 6
debug3: receive packet: type 96
debug2: channel 0: rcvd eof
debug2: channel 0: output open -> drain
debug3: receive packet: type 98                                                               <<<--- запрос от сервера на ввод
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug3: receive packet: type 97
debug2: channel 0: rcvd close
debug3: channel 0: will not send data after close

 

 

 

 

Это ответ SNR

 

Quote

debug3: Ignored env OLDPWD
debug2: channel 0: request shell confirm 1
debug3: send packet: type 98
debug2: channel_input_open_confirmation: channel 0: callback done
debug2: channel 0: open confirm rwindow 6000 rmax 1400
debug2: channel 0: read<=0 rfd 4 len 0
debug2: channel 0: read failed
debug2: channel 0: chan_shutdown_read (i0 o0 sock -1 wfd 4 efd 6 [write])
debug2: channel 0: input open -> drain
debug2: channel 0: ibuf empty
debug2: channel 0: send eof
debug3: send packet: type 96
debug2: channel 0: input drain -> closed
debug3: receive packet: type 99                                            <<<--- сервер не ожидает ответа, если я правильно понял RFC
debug2: channel_input_status_confirm: type 99 id 0
debug2: shell request accepted on channel 0
debug3: send packet: type 1
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:

 

Ну, как-то так.

 

Edited by surgeon

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.