Page 1 of 1

tcsetattr ~ICANON: Invalid argument

Posted: Fri May 19, 2017 6:43 am
by MichaelBrandl
Hi,

I'm writing a backup program which SSH's into the Device, pulls of the config, and then stores this where we want it to, the TFTP Backup isnt practical for us.

This works fine if I do it for a Cisco, Juniper, Mikrotik Etc.

However when I run a quick test using the below command it does show the data, but seems to error in a loop:


sshpass -p 'password' ssh -p 22 -o StrictHostKeyChecking=no admin@'ip' < netonix-commands.txt
The netonix-commands.txt file looks like this:


cmdline
cat config.json
exit
tcsetattr ICANON: Invalid argument
tcsetattr ~ICANON: Invalid argument
tcsetattr(): Invalid argument
tcsetattr ICANON: Invalid argument
tcsetattr ~ICANON: Invalid argument
tcsetattr(): Invalid argument
tcsetattr ICANON: Invalid argument
tcsetattr ~ICANON: Invalid argument
tcsetattr(): Invalid argument
tcsetattr ICANON: Invalid argument
tcsetattr ~ICANON: Invalid argument
Thanks


Mike

Re: tcsetattr ~ICANON: Invalid argument

Posted: Fri May 19, 2017 8:01 am
by sirhc
Curious what the TFTP backup lacks that you need?

Re: tcsetattr ~ICANON: Invalid argument

Posted: Fri May 19, 2017 5:00 pm
by MichaelBrandl
I'd really like security, centralised management of what I can back up, and the way I'm doing it I can have a separate file showing what changes were made.

Re: tcsetattr ~ICANON: Invalid argument

Posted: Fri May 19, 2017 6:13 pm
by jakematic
I use scp to pull the configs, but you need to setup a key pair and put it in /etc/dropbear/authorized_keys

Code: Select all
 scp admin@ws12:/www/config.json config.json

Re: tcsetattr ~ICANON: Invalid argument

Posted: Fri May 19, 2017 11:22 pm
by sirhc
MichaelBrandl wrote:I'd really like security, centralised management of what I can back up, and the way I'm doing it I can have a separate file showing what changes were made.


Then setup a log server and it records the save and what was changed

Re: tcsetattr ~ICANON: Invalid argument

Posted: Sat May 20, 2017 11:52 am
by mike99
MichaelBrandl wrote:sshpass -p 'password' ssh -p 22 -o StrictHostKeyChecking=no admin@'ip' < netonix-commands.txt
...
I'd really like security


sshpass is not considered secure since you keep in clear text the password of a device in your script. A simple error and everybody can access it. Kind of error I saw, stocking the scripts under the www folder. You switch should not change much so the method describe by jakematic is the secure way to do automatic remote ssh connection.

Re: tcsetattr ~ICANON: Invalid argument

Posted: Mon May 22, 2017 2:33 pm
by MichaelBrandl
It's all in PHP, and the files are ssl encrypted so the password isn't in plain text. However if someone could get onto the server they may be a problem.

Thanks for the advice and I'll try using a keypair and SCP.

Thanks

Mike