So I redefine the question: If the user selects for example AES and the server only supports ssh1, will the putty's core fallback to the next cipher in the list?
Yes it will. And if it falls below CIPHER_WARN then askcipher() is called.
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.
So I redefine the question: If the user selects for example AES and the server only supports ssh1, will the putty's core fallback to the next cipher in the list?
I have mailed you to the sourceforge address. (I don't know if you refer to that one)
Please, feel free to contact with me whenever you want. I'll be glad if I can help you with something.
I'm happy that finally I can help you in something. I was in debt with you as you have helped me a lot.
If I can help you with something I would be happy.
However I intend to add support for multithreading to the next version. So if you succeed, please send me some hint. Thanks.
I have been doing tests with the nopty to false and here are the results:
Under OpenSSH: If I send a ctrl+c (03), then I stop receiving output data from the command, but I don't get the command prompt.
Under F-Secure: The same, but it displays a message asking if I want to interrupt the batch command.
So why is it not working?
Please tell me that I have done something wrong, or that I have only to call sk_init only once in the whole program or something like this, because I'm desperated with this. I was so glad when all was working fine until I did the multisession test. As far as I know, all variables are shared within winnet.c, which means that the same sockets are used for all the sessions?? Is the "sktree" structure the cause?, and the Actual_Socket?
Yes, but only for the remote shell class.So you have set nopty to false?
Keep in mind, that you have to set it to true, for transfer connection.
And now I use a different way for detecting the end of a command: after stablishing connection I change the prompt (PS1 in unix-like and prompt in windows) so that every time I get the prompt means that the command is finished.
Ok, you're right. It works on OpenSSH server but not on F-Secure servers. I was doing all tests under an f-secure server.I'm sending '\n'. And it works. See my TSecureShell::SendLine().
In conclussion, the f-secure server is not compatible at all with the putty core. With the openSSH server I had no problems.
I open the shell and then I send commands. If I send any command ending with "\n" it does nothing, as it's only a new line char. I need to send "\r" (carriage return).
Is there any chance to interrupt a command by sending ctrl+c or anything to the server?(as the server does not process the "exit" command untill the former command is finished)
Finally, what are these functions/attributes used for?
back->unthrottle()
back->sendbuffer()
noise_ultralight()
cfg.nopty
cfg.tcp_nodelay
nodelay in the call to back->init()
1) Receiving data:
You cannot just wait for from_backend() to be called. You must do something like sftp_recvdata() from psftp.c does (there are several such functions in Putty, at least one for each application). sftp_recvdata() is implementation for synchronous applications, so you need to know how much data you are going to read. I solve this in WinSCP, by sending commands like 'ls ; echo "this is end"' and then I read line by line until I find 'this is end'. Then I know that I should not expect any more output and I can send another command.
There maybe asynchronous implementation in plink or putty itself, if you need it. I have not, so I do not know.
2) Sending data.
Yes, you need to call sendbuffer() too. See my TSecureShell::Send(). Important here is TSecureShell::WaitForData() too, which is used both for sending and receiving. It is the same as for example ssh_sftp_loop_iteration() from winsftp.c does. It is used for sftp_recvdata(), but I do not see it being used for sending. Maybe something has changed and it may not be necessary to call it for sending anymore. The same may apply for my WaitForData(), but it seems still working as it is.
3) Terminating connection.
If you are going to execute only one command (I do not remember, sorry), then you may specify it in cfg.remote_cmd. Than the server will terminate connection once the command is finished.
If you need to open shell, than you may terminate it using "exit\n". However I do not do it in WinSCP :-)
For the sample you wrote about, it should not work, if I understood correctly that b.bat is running endlessly. Then "exit\n" cannot be received by the shell, as the control is never returned to the shell.
(char)*data = '\0';
return 0;
From the text below, I've understood that you are going to only to execute some commands of your own. Do you? Why do you than talk about SFTP? Or would you like to transfer file as well? Sorry, I've lost a track of your problem and I do not have time to read your previous posts :-(
No problem. Now I see that you understand the things finally and the questions get to the point. So it is much easier to answer.
Sure. That's one of the points where my classes TSFTPFileSystem and TSCPFileSystem differ.
Finally I have managed to implement a wrapper class for putty with SFTP functionality.
I think that SSH v2 is supported by more servers than SSH v1, and almost all servers that supports SSH v1 also supports SSH v2 nowadays, so I have made only SFTP and no SCP implementation.
Personally I think that's better to add the frontend parameter to the function than using mutexes, but this leads to a ssh core modiffication and have to be made every time you upgrade the putty core.
Am I wrong about this? So from_backend should differ the session method (sftp and shell) and call different members of the wrapper class in order to process the data received in a sftp connection and the data from a shell.
Is this ok?
*What are cfg.ssh_subsys and cfg.ssh_subsys2 for? Concretelly I had to change the cfg.ssh_subsys parameter in order to be able to execute the notepad remotelly.
If I assign TRUE to cfg.ssh_subsys it throws the above error. And it works if I assign FALSE.
*What is the use of cfg.remote_cmd2 if there is cfg.remote_cmd?
I know cfg.remote_cmd_ptr is for providing long commands, but what is cfg.remote_cmd2 for?
*When clossing a session all commands and programs launched in that session are killed. Is there any way to prevent closing them? Does this happen with all servers or this is F-Secure related?
(Take your time to reply, it's a very long post (I'm sorry for that, but you are the only one that I know that can help me))
if (!ssh_get_line(s->pwprompt, s->password, sizeof(s->password), TRUE));
GLOBAL int (*ssh_get_line) (void *frontend, const char *prompt, char *str, int maxlen, int is_pw);
"Unexpected response to shell/command request: packet type 98"
Then why WinSCP can't loggin with SCP protocol in an SSHv2 server?
SCP can work even in SSH2. Just place scp and scp1 binaries in path. Also as I have already wrote, you do not need Plink sources to execute commands! See some ports above.
Because SSH2 does not support SCP protocol, and with SFTP protocol you can't execute commands, so I will need to integrate also the plink files in order to execute commands with SSH2.
I don't know at all, as you can see I know nothing from SSH protocol, I'm only guessing. I don't have the time to go in deeper into the SSH (1 & 2) protocol.
Why you cannot use the trick for SSH2?
And now I need for sure to integrate also with the plink and pscp files (double work, I can't make the trick of the scp protocol to launch commands in SSH2)
so with all these information what do you recommend me now?
Problem with PSCP is AFAIK that for every single transfer you need to launch new instance of program and to complete the authentication, which may take several seconds.
Problem with PSCP is AFAIK that for every single transfer you need to launch new instance of program and to complete the authentication, which may take several seconds.
What do you think about this interface/wrapper class method? Is better to implement it like in your program or is this way ok?
And finally another question: I have been working a lot, but still I have a lot of job to do, and I have thought of using pscp and plink as command line processes, just deffining pippes and redirecting it to the pscp and plink stdin, stdout and stderr and then send commands through the stdin pipe and receive results and errors throught the others. I think it should be much easier but not so clean and efficient. I want to know your oppinion and suggests about this question.
So the question is: What do you think that should be easier? Adapt your class/es or build from zero my own one with your class as a reference?
There is a bug in C++ Builder that causes it. But as you have succeeded in compiling it already, I would not write you workaround now.
Debug info is probably stripped from EXE file. In Project options dialog, click "full debug" button, save the project and make it again (using makefile). You probably need to do this for every library as well.
TSecureShell class (core\SecureShell.cpp) in WinSCP is the wrapper around the Putty functionality.
Estabilish connection: Look what PSCP does. In scp.c see Init() function. It calls back->init(). And then back->sendok() in loop in function ssh_scp_init(). Transfer files: Again take pscp as example. Keep one thing in mind, PSCP despite its name in both SCP and SFTP client, so it's code looks now rather complex comparing with time it was SCP-only client. I don't know what protocol do you want to use. SCP is simpler, while SFTP is much better. With SCP you cannot interrupt file transfer in middle without closing the connection, it does not allow transfer resume, and much more.
You do not need anything more as I have already wrote once. To use second method: leave Config.remote_cmd_ptr blank and after estabilishing connection, putty opens default user shell. If you want to force particular shell (like BASH), set Config.remote_cmd_ptr to that shell (e.g. '/bin/bash'). Than send command to execute via back->send() and back->sendbuffer(), see TSecureShell::Send().
but when I tried to compile the putty library project it gave me a bunch of errors like "unix.h" not found, some errors in putty.org.h and so on (I don't know what I did wrong).
tried to trace the code from the start, but the "trace into" command launched the executable without letting me trace a single line of code, and the "step over" command started tracing machine code instead of the c++ code.
- Separate the files I need (for example the files that pscp links expect scp.cpp of course). Make a library project with this.
- Implement some funcions that are in scp.cpp that the ssh core calls back with results (as you did in PuttyIntf.c). This uses tha above library.
- Implement a class which wraps the Config struct and some functions to stablish the connection, transfer, etc. These functions should call the ssh core functions with the data in the Config struct (one struct per object, so I should work with multiple connections and multithreading).
But I'm not sure at all, it's only the idea I have formed in my mind with your answers and a short look at the code.
and also if you point what functions I have to call in order to stablish a connection, transfer files and launching commands.
I don't know I will need some more files that the ones that pscp links.
About the launching commands issue: I only whant to launch an executable per session, so I think that the first method should be enough, but I think that some times I will need to launch more than one command per session, for example before retrieving files checking the time and date to not transfer the file if it haven't changed since the last time. So I think I will need the second method, but... for this method is necesary to link any more files than pscp does?
Sorry for that, it was an understandable question.
What I mean with the thirth question is that in the gui that I'm developping I need to execute binaries in remote machines and transfer files from them, so I ask if with the pscp project files would be enough for this 2 features or may I need to include also the plink source files in the project?
You have the best support I have seen ever! :P
What's the purpose of using the same registry keys? Does putty stores some function results in the registry?
If I need to launch binaries and transfer files is correct to use plink and pscp project files? or maybe it's enought with the pscp files?
Next thing it does is that it overrides standard RegOpenKey and RegCreateKey, so Putty reads from WinSCP registry key, instead its own one.
Thank you very much for your help!
The problem is that the source version I have from putty is different from the version that comes with the last WinSCP release, so I had been comparing the putty files with a compare and merge tool and have found some code in putty.h that I thought you added it for integrating with WinSCP.