Community discussions

MikroTik App
用户头像
skot
Long time Member
Long time Member
Topic Author
Posts: 584
加入: Wed Nov 30, 2011 3:05 am

SSH between routers, works in terminal but not in script?

Wed May 23, 2012 2:17 am

I'm using SSH and DSA keys between 2 MikroTik routers on v5.7. The following works fine in the terminal, but when I put it in a script / scheduler / netwatch, it does not work. Any ideas?
Code:Select all
/system ssh 192.168.0.5 user=Test "/log info testing"
Top
klolik79
刚刚加入了
Posts: 1
加入: Tue Jul 31, 2012 2:15 pm

Re: SSH between routers, works in terminal but not in script

Tue Jul 31, 2012 3:26 pm

Hi guys,

I've got the same issue. If there's no allocated terminal, SSH server seems not to run command, or not to return it's output.
It does not seem to exist up to 5.16 (included), but exists in 5.18 and 5.19. I have not checked 5.17.
There's no difference between key-auth and password-auth.
Analogous case works if ssh-server is run on non-RouterOS system (freebsd to be exact), so this is not an ssh-client issue.

172.16.6.145 has RouterOS 5.19 and 172.16.5.223 has 5.16.

This two work perfectly as the should:
[] #ssh -i /root/.ssh/backup_id_dsa admin@172.16.6.145 '/system identity print'
name: XXXXX
[] #ssh -i /root/.ssh/backup_id_dsa admin@172.16.5.223 '/system identity print;' name: XXXXX
[] #echo "/system identity print" |ssh -i /root/.ssh/backup_id_dsa admin@172.16.5.225
Pseudo-terminal will not be allocated because stdin is not a terminal.
名称:“XXXXX”
#

and these do not (first four are quite the same):
[] #ssh -i /root/.ssh/backup_id_dsa admin@172.16.6.145 '/system identity print' [] #ssh -i /root/.ssh/backup_id_dsa admin@172.16.6.145 '/system identity print;' [] #ssh -i /root/.ssh/backup_id_dsa admin@172.16.6.145 'system identity print' [] #ssh -i /root/.ssh/backup_id_dsa admin@172.16.6.145 system identity print [] #echo "/system identity print" |ssh -i /root/.ssh/backup_id_dsa admin@172.16.6.145
Pseudo-terminal will not be allocated because stdin is not a terminal.
[] #

ssh client:
[] #ssh -V
OpenSSH_5.8p2 FreeBSD-openssh-portable-5.8.p2_2,1, OpenSSL 0.9.8e 23 Feb 2007

Routerboard having the issue:

[admin@Mikrotik] > /ip address print
Flags: X - disabled, I - invalid, D - dynamic
# ADDRESS NETWORK INTERFACE
0 ;;; default configuration
172.16.6.145/24 172.16.6.0 bridge1

[admin@Mikrotik] > /system resource print
uptime: 8m30s
version: 5.19
free-memory: 49204KiB
total-memory: 62184KiB
cpu: MIPS 24Kc V7.4
cpu-count: 1
cpu-frequency: 300MHz
cpu-load: 2%
free-hdd-space: 89432KiB
total-hdd-space: 126976KiB
write-sect-since-reboot: 199
write-sect-total: 73058
bad-blocks: 0%
architecture-name: mipsbe
board-name: RB433
platform: MikroTik
[admin@Mikrotik] > /system routerboard print
routerboard: yes
model: 433
serial-number: XXXXXXXXXXXX
current-firmware: 2.41
upgrade-firmware: 2.41
[admin@Mikrotik] > /ip ssh print
forwarding-enabled: no
always-allow-password-login: yes


Best regards,
Bartlomiej Korupczynski
Top

Who is online

Users browsing this forum: No registered users and 11 guests