Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-08

SSH

22 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Richard Mace

Hi All,
I am needing to add the ability to my Lazarus application to copy files to a linux server.
Assuming that my application will be run on Windows, what's the best way of copying files to and from a Linux box?
I've heard that the pgp command in putty might work, but I was just wondering if there was a component for Lazarus that would make things easier?

Thanks in advance

Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130801/8221c362/attachment.html>

Reply by email

Michael Schnell
to Richard Mace
Richard Mace wrote
I am needing to add the ability to my Lazarus application to copy files to a linux server. Assuming that my application will be run on Windows, what's the best way of copying files to and from a Linux box?

Ignoring the Subject I's just recommend a file sharing protocol such as CIFS.

But if you need to use SSH, I do know how this might work (i.e. you need to start (e.g.) "cp" on the target via SSH), but I don't know any pascal code that uses SSH.

I've heard that the pgp command in putty might work, but I was just wondering if there was a component for Lazarus that would make things easier?

Putty in fact can do ssh. AFAIK, ssh uses pgp as it's encryption algorithm.

-Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130801/ece36f31/attachment.html>

Reply by email

Reinier Olislagers
to Michael Schnell
Michael Schnell wrote 7 lines
On 08/01/2013 07:48 AM, Richard Mace wrote: > I am needing to add the ability to my Lazarus application to copy > files to a linux server. > Assuming that my application will be run on Windows, what's the best > way of copying files to and from a Linux box? Ignoring the Subject I's just recommend a file sharing protocol such as CIFS.

Why? SSH/SCP works much better/more securely if accessing servers across the internet. No need to mess with VPNs etc.

But if you need to use SSH, I do know how this might work (i.e. you need to start (e.g.) "cp" on the target via SSH), but I don't know any pascal code that uses SSH.

Wiki:
http://wiki.lazarus.freepascal.org/synapse#SSH.2FTelnet_client_sample_program

Show quoted text 5 lines
> I've heard that the pgp command in putty might work, but I was just > wondering if there was a component for Lazarus that would make things > easier? > Putty in fact can do ssh. AFAIK, ssh uses pgp as it's encryption algorithm.

No.
SSH uses algorithms like DES, 3DES, AES for encryption. I strongly suspect they don't use the same algorithms as pgp for authentication/key exchange.

What Richard perhaps meant is the pageant utility included with Putty.

Reply by email

Antonio Fortuny
to Michael Schnell: Ignoring the Subject I's just recommend a file sharing protocol such as CIFS. But if you…

Le 01/08/2013 09:58, Michael Schnell a ?crit :

Show quoted text 7 lines
On 08/01/2013 07:48 AM, Richard Mace wrote: > I am needing to add the ability to my Lazarus application to copy > files to a linux server. > Assuming that my application will be run on Windows, what's the best > way of copying files to and from a Linux box? Ignoring the Subject I's just recommend a file sharing protocol such as CIFS.

I agree with Michael. On one hand you can configure a SaMBa server in the Linux box which then can be accessed like any other windows machine using the UNC naming syntax.
On the other hand you can use an SSH compliant component anyway. Like Indy 10 that I use since a few years. It compiles and runs under Lazarus (some minor changes are needed though for a successful compilation). This method is a little bit more difficult to implement and quite tricky but it works.
I use the traditional pair login/password for identification. The SSH Indy component and the Linux box manage themselves the SSH encrytion protocol

Antonio.

Show quoted text 20 lines
But if you need to use SSH, I do know how this might work (i.e. you need to start (e.g.) "cp" on the target via SSH), but I don't know any pascal code that uses SSH. > I've heard that the pgp command in putty might work, but I was just > wondering if there was a component for Lazarus that would make things > easier? > Putty in fact can do ssh. AFAIK, ssh uses pgp as it's encryption algorithm. -Michael -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130801/ad16ff97/attachment.html>

Reply by email

Reinier Olislagers
to Michael Schnell: He did not mention "Internet". -Michael
Michael Schnell wrote 6 lines
On 08/01/2013 10:04 AM, Reinier Olislagers wrote: > On 01/08/2013 09:58, Michael Schnell wrote: > Why? SSH/SCP works much better/more securely if accessing servers across > the internet. He did not mention "Internet".

That's a strange response.
*He* specified SSH, not samba - you came up with that yourself. I was just pointing out why SSH can be a cleaner/less complicated solution (yes, when dealing with internet connections) than samba in response to your bringing up samba.

Anyway, I'm certainly interested in hearing about getting SCP to work using Synapse...

Reply by email

Mark Morgan Lloyd
to Reinier Olislagers: Why? SSH/SCP works much better/more securely if accessing servers across the internet. No…
Reinier Olislagers wrote 10 lines
> Ignoring the Subject I's just recommend a file sharing protocol such as > CIFS. Why? SSH/SCP works much better/more securely if accessing servers across the internet. No need to mess with VPNs etc. > But if you need to use SSH, I do know how this might work (i.e. you need > to start (e.g.) "cp" on the target via SSH), but I don't know any pascal > code that uses SSH. Wiki: http://wiki.lazarus.freepascal.org/synapse#SSH.2FTelnet_client_sample_program

An important point about SSH is that it separates authentication (i.e. password submission, certificate checking etc.) from normal traffic. So leaving aside the desirability of not passing passwords around "in clear", there's no longer any need for the client to parse a login prompt from the server, and to some extent the client can retain a password once entered and use it for multiple sessions.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Mark Morgan Lloyd
to Michael Schnell: Yep. I supposed he mentioned SSH because he knows that he can access the server via PUTTY…
Michael Schnell wrote 5 lines
On 08/01/2013 10:32 AM, Reinier Olislagers wrote: > That's a strange response. *He* specified SSH, Yep. I supposed he mentioned SSH because he knows that he can access the server via PUTTY using the SSH protocol. I do exactly this with my local Linux servers.

Also he /specifically/ said that it was a Linux server, and that's more likely to have SSH in its default configuration than Samba, NFS, RSH or even FTP. I had a very similar discussion with an embedded system guy elsewhere earlier in the week, except that in his case he couldn't get his head around the idea that SSH was good for anything except shell sessions.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Sven Barth
to Michael Schnell: If this is "internet", he might want to install a VPN and with that he can use CIFS. So…
Michael Schnell wrote 8 lines
On 08/01/2013 10:04 AM, Reinier Olislagers wrote: > Why? SSH/SCP works much better/more securely if accessing servers > across the internet. No need to mess with VPNs etc. If this is "internet", he might want to install a VPN and with that he can use CIFS. So his pascal project is not bothered with dirty details of the file transfer.

In that case he could also try SSHFS which let's him mount a remote directory through SSH (I didn't test that myself though as of yet): http://en.wikipedia.org/wiki/SSHFS

Regards,
Sven

Reply by email

Mark Morgan Lloyd
to Sven Barth: In that case he could also try SSHFS which let's him mount a remote directory through SSH…
Sven Barth wrote 12 lines
Am 01.08.2013 10:29, schrieb Michael Schnell: > On 08/01/2013 10:04 AM, Reinier Olislagers wrote: >> Why? SSH/SCP works much better/more securely if accessing servers >> across the internet. No need to mess with VPNs etc. > If this is "internet", he might want to install a VPN and with that he > can use CIFS. > > So his pascal project is not bothered with dirty details of the file > transfer. In that case he could also try SSHFS which let's him mount a remote directory through SSH (I didn't test that myself though as of yet): http://en.wikipedia.org/wiki/SSHFS

Which I suppose begs the question of whether a FUSE VFS could be written in FPC.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Sven Barth
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 17 lines
Sven Barth wrote: > Am 01.08.2013 10:29, schrieb Michael Schnell: >> On 08/01/2013 10:04 AM, Reinier Olislagers wrote: >>> Why? SSH/SCP works much better/more securely if accessing servers >>> across the internet. No need to mess with VPNs etc. >> If this is "internet", he might want to install a VPN and with that >> he can use CIFS. >> >> So his pascal project is not bothered with dirty details of the file >> transfer. > In that case he could also try SSHFS which let's him mount a remote > directory through SSH (I didn't test that myself though as of yet): > http://en.wikipedia.org/wiki/SSHFS Which I suppose begs the question of whether a FUSE VFS could be written in FPC.

Considering that there is a C example for writing a FUSE VFS ( http://sourceforge.net/apps/mediawiki/fuse/index.php?title=Hello_World ) the answer is yes.
We also already have a FUSE unit in packages and it seems to be ready for FUSE more modern versions (e.g. 2.8) the unit needs to be recompiled (and for 2.9 it might need to be updated).

Regards,
Sven

Reply by email

Richard Mace
to Reinier Olislagers: Why? SSH/SCP works much better/more securely if accessing servers across the internet. No…
Show quoted text 31 lines
On 08/01/2013 07:48 AM, Richard Mace wrote: >> I am needing to add the ability to my Lazarus application to copy >> files to a linux server. >> Assuming that my application will be run on Windows, what's the best >> way of copying files to and from a Linux box? > Ignoring the Subject I's just recommend a file sharing protocol such as > CIFS. Why? SSH/SCP works much better/more securely if accessing servers across the internet. No need to mess with VPNs etc. > But if you need to use SSH, I do know how this might work (i.e. you need > to start (e.g.) "cp" on the target via SSH), but I don't know any pascal > code that uses SSH. Wiki: http://wiki.lazarus.freepascal.org/synapse#SSH.2FTelnet_client_sample_program >> I've heard that the pgp command in putty might work, but I was just >> wondering if there was a component for Lazarus that would make things >> easier? >> > Putty in fact can do ssh. AFAIK, ssh uses pgp as it's encryption algorithm. No. SSH uses algorithms like DES, 3DES, AES for encryption. I strongly suspect they don't use the same algorithms as pgp for authentication/key exchange. What Richard perhaps meant is the pageant utility included with Putty.

Yes, and thanks for all of the input.
I am writing an app in Lazarus, that will manipulate files locally, and then these files will get uploaded to a Linux box. In my mind it makes sense to transfer the files via psftp (Putty) as it's very common/easy to set-up ssh on a Linux box. Ideally, I would like to have a Lazarus component to do this, but I am also happy to "shell out" to psftp (via Lazarus), I just need the funtionality to be as user friendly as possible, as many of my users will have never even seen a Linux command line before :)

Thanks again for everyone's input

Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130801/b7b38c83/attachment-0001.html>

Reply by email

Michael Schnell
to Richard Mace
Richard Mace wrote
... as many of my users will have never even seen a Linux command line before :)

What exactly are you up to?

We still don't know how the targeted setup is supposed to be.

E.g.
- a Windows computer in a company network that can access a Linux box in the server room with the IT department managing the installation of any software on trhe users desktop
- you send your software to a dummy user somewhere in the world and he is supposed to install and run it and access a Linux box via the Internet.

With the first obviously CIFS (aka Samba) is the way to go: Easy stuff, as you program just calls the file operations provided by the RTL.

With the second example "easy software" s not really possible:
- at best only your program should be installed and no additional components such as Putty, VPN, dlls done in C, ... should be necessary to be installed and no manual setup of SSH key should be necessary that means the complete protocol should be managed by (Pascal) software
- the user might sit behind a firewall that forbids any protocol other than the use of of HTTP(S) and requires the use of a proxy server.
- if you need encryption (such as HTTPS) you supposedly need an SSH key provider server (either locally on the Linux box or "officially certified")

In that case I recommend using http (or https) upload (AFAIK, this is available with Synapse).
Of course here you need to configure the Linux box to have a HTTP server and provide the upload service.

-Michael

Reply by email

Michael Schnell
Richard Mace wrote 64 lines
On 2 August 2013 09:12, Michael Schnell < <mailto:>>wrote: On 08/01/2013 05:20 PM, Richard Mace wrote: ... as many of my users will have never even seen a Linux command line before :) What exactly are you up to? We still don't know how the targeted setup is supposed to be. E.g. - a Windows computer in a company network that can access a Linux box in the server room with the IT department managing the installation of any software on trhe users desktop - you send your software to a dummy user somewhere in the world and he is supposed to install and run it and access a Linux box via the Internet. I need it to be as standard and easy as possible to copy files to and from a Windows box to a Linux server, one that has been freshly built for the task., and would have probably have been built by an IT gut that would be able to make sure that SSH is configured through the firewall. I'm expecting that most of the time, the Linux box will be on the local network, so ssh should be fine. If I went down the samba, I would need additional configuration setup, which could put barriers in the way of using my software for no reason? With the first obviously CIFS (aka Samba) is the way to go: Easy stuff, as you program just calls the file operations provided by the RTL. With the second example "easy software" s not really possible: - at best only your program should be installed and no additional components such as Putty, VPN, dlls done in C, ... should be necessary to be installed and no manual setup of SSH key should be necessary that means the complete protocol should be managed by (Pascal) software - the user might sit behind a firewall that forbids any protocol other than the use of of HTTP(S) and requires the use of a proxy server. - if you need encryption (such as HTTPS) you supposedly need an SSH key provider server (either locally on the Linux box or "officially certified") In that case I recommend using http (or https) upload (AFAIK, this is available with Synapse). Of course here you need to configure the Linux box to have a HTTP server and provide the upload service. -Michael I have currently got SSH working, by creating a TProcess in Lazarus and calling pfstp to copy the file to and from the Linux box, and the pslink to run a command on the Linux box.

Where do "pfstp" and "pslink" come from ?

It would be great to see these (or similar stuff) in TCP/IP libraries such as Synapse.

-Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130805/8b1d3865/attachment-0001.html>

Reply by email

Michael Schnell
to Reinier Olislagers
Reinier Olislagers wrote
Sigh. Putty. Richard mentioned that in his first post.

I did suppose so, but neither pfstp nor pslink has been mentioned before Richards last post:
"I have currently got SSH working, by creating a TProcess in Lazarus and calling pfstp to copy the file to and from the Linux box, and the pslink to run a command on the Linux box."

And he did say that he did not like the idea of installing anything on the Windows box to make his System run.

(In fact he might consider to put the "pfstp" and "pslink" executables in a resource, but that might be problematic due to user rights on Windows.

http://en.wikipedia.org/wiki/SFTP_%28disambiguation%29: Is "SFTP" here really "Secure FTP (via SSH) " (
http://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol ) or rather "Simple FTP" ? (
http://en.wikipedia.org/wiki/Simple_File_Transfer_Protocol )

Rather ambiguous naming :(.

-Michael

Reply by email