EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Is it possible to modify text file through SSH

Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.
Posted: 08/31/2009 21:58:36
by johnny  (Standard support level)
Joined: 08/20/2009
Posts: 19

I want to have an interface built with VB.net and Secure blackbox SSH client to tunnel to Linux server. Based on the option selected by the VB user, I need to modify some standard text file accordingly (like delete, add, or modify), after that save the changes.

Is it possible to do this with SSH simple client? or other software?

thanks and regards,

Posted: 09/01/2009 00:08:34
by Ken Ivanov (EldoS Corp.)

Thank you for contacting us.

The answer depends on the configuration and capabilities of the server. The easiest way would be to use SFTP (which is a file transfer protocol running over a secure SSH channel), however, this requires a server to have the corresponding subsystem set up. Most of Linux distributions install OpenSSH server software, which has the SFTP subsystem enabled by default.

Raw SSH client can be used as well, however, it is not a natural way to access server-side file system. As SSH does not provide built-in means for accessing remote files, you will be forced to use remote shell commands to perform your task.
Posted: 09/02/2009 01:16:02
by johnny  (Standard support level)
Joined: 08/20/2009
Posts: 19

Thank for your reply Innokentiy Ivanov.

Am i correct that if I use SFTP to access the remote Linux file, I need to create a temporary file in local computer, send over the new file to linux and replace the old linux file?

Or I can modify the Linux file remotely without replacing the whole file via SFTP?

I shall try it on my own later on to have a better feeling.
Posted: 09/02/2009 02:07:34
by Ken Ivanov (EldoS Corp.)

First, what exactly do you mean by saying "access" and "modify" the remote file?

SFTP supports random access to the remote files with Open(), Read() and Write() calls, exactly as if the files were stored on local file system. Please see the corresponding methods of TElSimpleSFTPClient class.
Posted: 09/07/2009 01:15:05
by johnny  (Standard support level)
Joined: 08/20/2009
Posts: 19

Hi, By saying "access" and "modify", Like what I did through putty.

I can open the file using vi editor, and change the content of the files accordingly, and save the file after done using ":wq" command.

Can this be done using SFTP as well?
Posted: 09/07/2009 01:35:57
by Ken Ivanov (EldoS Corp.)

Well, there are two ways then:

a) you can set up a remote shell, run vi under it and introduce all the necessary changes manually (or emulate manual work by sending commands and control characters through SSH connection from your code),

b) you can introduce the necessary changes to the file with SFTP by using the methods I have mentioned above (Open(), Read(), Write(), Close()).
Posted: 09/09/2009 02:44:17
by johnny  (Standard support level)
Joined: 08/20/2009
Posts: 19

thanks a lot Ivanov,

I shall give a try to SFTP as SSH is a lot more complex to do if I am correct.

Also by EldoS: CallbackProcess
A component to control process creation and termination in Windows and .NET applications.



Topic viewed 1208 times

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


Back to top

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

Got it!