Jump to content
João Bosco

How to Create a RSA key using CMD by Delphi

Recommended Posts

I'm using the "SSH_Pascal" library and creating an SSH connection via delphi.

After a lot of effort I discovered that it is necessary to have your RSA key and your host in this file called "known_hosts" in windows it is usually at: %USERPROFILE% + .ssh\known_hosts

To create an RSA key using openSSH via CMD is simple, see the command:

ssh-keyscan -t rsa your host


There, your RSA key is created.

The only difficulty I'm having is getting this RSA via cmd and adding it to the file.

the simplest way through cmd would be: ssh-keyscan -t rsa your host > %USERPROFILE% + .ssh\known_hosts To insert the value into the file.

But using by delphi is not working.

 

I tried using a function(GIst.Github) to get the DOS output, without success.

When it enters This step of the Function

WasOK := ReadFile(StdOutPipeRead, Buffer, 255, BytesRead, nil);

it hangs It just hangs.

 

I've tried to increase the buffer size but without success, does anyone have any ideas?

 

 

Share this post


Link to post
22 hours ago, João Bosco said:

I'm using the "SSH_Pascal" library and creating an SSH connection via delphi.

After a lot of effort I discovered that it is necessary to have your RSA key and your host in this file called "known_hosts" in windows it is usually at: %USERPROFILE% + .ssh\known_hosts

To create an RSA key using openSSH via CMD is simple, see the command:


ssh-keyscan -t rsa your host


There, your RSA key is created.

The only difficulty I'm having is getting this RSA via cmd and adding it to the file.

the simplest way through cmd would be: ssh-keyscan -t rsa your host > %USERPROFILE% + .ssh\known_hosts To insert the value into the file.

But using by delphi is not working.

 

Redirection is function of the command processor. The easiest way to use it from a Delphi program is to write the commnd line with the redirection to a batch file (.bat or .cmd) and then simply run that via ShellExcecute, IMO.

 

 

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×