EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Using SSH waiting for command to finish

Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.
Posted: 09/18/2013 01:35:34
by Anthony Wilder (Standard support level)
Joined: 05/09/2013
Posts: 8

1. Thought I would attach the full code that I am using.( runSSH.pas )
2. Completely failed means that none of the commands got executed.
3. Added "ls -l /" at your request below is results. Results show that it does not like that path either.


<14>1 2013-09-18T16:31:13.394+10:00 BRDBAdmin.exe 1236 - - ls -l /
<14>1 2013-09-18T16:31:13.395+10:00 BRDBAdmin.exe 1236 - - chown -f firebird:firebird /data/burgesV2/data/backup/op.old
<14>1 2013-09-18T16:31:13.395+10:00 BRDBAdmin.exe 1236 - - mv -f /data/burgesV2/data/backup/op.old /data/burgesV2/data/op.oldtest
<14>1 2013-09-18T16:31:13.396+10:00 BRDBAdmin.exe 1236 - - chown -f firebird:firebird /data/burgesV2/data/op.oldtest
<14>1 2013-09-18T16:31:13.652+10:00 BRDBAdmin.exe 1236 - - Server key received (RSA). Fingerprint is 5c:2d:2c:0f:98:45:23:ec:29:8c:48:ed:28:69:ba:e8
<14>1 2013-09-18T16:31:13.796+10:00 BRDBAdmin.exe 1236 - - Authentication succeeded
<14>1 2013-09-18T16:31:13.869+10:00 BRDBAdmin.exe 1236 - - Connection started
<14>1 2013-09-18T16:31:13.869+10:00 BRDBAdmin.exe 1236 - - Server: OpenSSH_5.3
<14>1 2013-09-18T16:31:13.870+10:00 BRDBAdmin.exe 1236 - - Version: SSHv2
<14>1 2013-09-18T16:31:13.870+10:00 BRDBAdmin.exe 1236 - - PublicKey algorithm: 1
<14>1 2013-09-18T16:31:13.871+10:00 BRDBAdmin.exe 1236 - - Kex algorithm: 3
<14>1 2013-09-18T16:31:13.874+10:00 BRDBAdmin.exe 1236 - - Block algorithm: 16
<14>1 2013-09-18T16:31:13.874+10:00 BRDBAdmin.exe 1236 - - Compression algorithm: 0
<14>1 2013-09-18T16:31:13.875+10:00 BRDBAdmin.exe 1236 - - MAC algorithm: 11
<14>1 2013-09-18T16:31:14.383+10:00 BRDBAdmin.exe 1236 - - Connection closed.
<14>1 2013-09-18T16:31:14.384+10:00 BRDBAdmin.exe 1236 - - bash: ls -l /: No such file or directory bash: chown -f firebird:firebird /data/burgesV2/data/backup/op.old: No such file or directory bash: mv -f /data/burgesV2/data/backup/op.old /data/burgesV2/data/op.oldtest: No such file or directory bash: chown -f firebird:firebird /data/burgesV2/data/op.oldtest: No such file or directory

[ Download ]
Posted: 09/18/2013 01:40:26
by Eugene Mayevski (Team)

Thank you for the code and tests. Looks like Bash for some reason doesn't accept compound command at all.

We will try to reproduce the issue locally today.

Sincerely yours
Eugene Mayevski
Posted: 09/18/2013 05:54:26
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

Just checked - OpenSSH correctly runs semicolon-separated commands.
The only possible reason I see is that server runs command tunnel in chrooted environment. Please check server's configuration.
Posted: 09/18/2013 17:40:58
by Anthony Wilder (Standard support level)
Joined: 05/09/2013
Posts: 8

If it were a problem with the chroot setup then the Client.Commands property would fail, Is that right? However when using the "Commands" property the process works. The only issue with the "Client.commands" property, is that it does not wait for the list of commands to finish executing before it returns.

We use CentOS 6.3.
Posted: 09/19/2013 01:27:27
by Eugene Mayevski (Team)

We are not linux experts either, so you need to ask the person who installed and configured the system.

On our side we've carried several tests and ensured that commands passed in Commands property are executed consequently, and the script works as well when all commands are passed using Command property concatenated.

I must note that some buggy servers (eg. VanDuyke in some ) can close the channel before the command is completed (but your openssh should not - we tested with it), so this way is not very reliable.

There's one possible thing to test in your configuration - start SSHDEmo sample (not CmdSSHDemo!) in <SecureBlackbox>\Samples\<language>\SSHBlackbox\Client and try to execute your commands. They will go via Shell tunnel (not command tunnel) - I wonder what the server's behavior will be then.

Sincerely yours
Eugene Mayevski
Posted: 09/19/2013 02:27:33
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

To check chroot you should open your sshd_config and search for 'ChrootDirectory' directive.
Also by EldoS: CallbackDisk
Create virtual disks backed by memory or custom location, expose disk images as disks and more.



Topic viewed 3975 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!