Topic "Server refused to start a shell/command"

Author Message
rukfa
[View user's profile]

Joined: 2015-02-11
Posts: 5
Location: Sarajevo
Hi there! I just can't get this darn thing to work! I need to download files from folder, check if they all have been transferred, then delete if they have. I've tried using session.GetFiles("folder","folder",true,null), but this deletes whole folder which is bad. I've also tried using session.RemoveFiles, but it just won't delete files one by one on the remote server. Now I'm trying to use session.ExecuteCommand, but the following problem arises. I'm using .ppk private key to authenticate with server, and for SFTP I use CORE FTPServer. Please HELP! Also, there is no option on the server to allow shell/command.

Authentication failed.Exception: Server refused to start a shell/command

Inner exception: WinSCP.SessionRemoteException: Authentication log (see session log for details):
Using username "faruk".
Authenticating with public key "rsa-key-20150211".

Authentication failed.

Log from server:

[20150211 13:39:43] [xxx.xxx.xx.xx] connecting

[20150211 13:39:43] [xxx.xxx.xx.xx] connected

[20150211 13:39:44] [xxx.xxx.xx.xx] user (faruk) granted access

[20150211 13:39:44] [xxx.xxx.xx.xx] connecting

[20150211 13:39:44] [xxx.xxx.xx.xx] connected

[20150211 13:39:46] [xxx.xxx.xx.xx] user (faruk) granted access

[20150211 13:39:46] [xxx.xxx.xx.xx] disconnected (faruk)

[20150211 13:39:46] [xxx.xxx.xx.xx] disconnected (faruk)



Also chunk of my code:

SessionOptions options = new SessionOptions
{
Protocol = Protocol.Sftp,
HostName = "xxx.xxx.xx.xx",
UserName = "faruk",
Password = "xxxxxx",
SshPrivateKeyPath = @"path\priv.ppk",
GiveUpSecurityAndAcceptAnySshHostKey = true
};

using (Session session = new Session())
{
session.Open(options);

session.ExecuteCommand("cd folder");
...
}
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24553
Location: Prague, Czechia
You probably want to do session.GetFiles("folder/*","folder\",true,null). This won't delete the folder, just the files in it.
_________________
Martin Prikryl
rukfa
[View user's profile]

Joined: 2015-02-11
Posts: 5
Location: Sarajevo
I know that, and that's great, and it works! Unfortunately, after I've downloaded files locally, I can't delete them using session.RemoveFiles. It works on my computer, but it won't budge on server, so I'm trying to use commands.
rukfa
[View user's profile]

Joined: 2015-02-11
Posts: 5
Location: Sarajevo
Ahhh, sorry man, I've tried this approach, but it won't do the trick Sad
Just nothing happens...
rukfa
[View user's profile]

Joined: 2015-02-11
Posts: 5
Location: Sarajevo
I don't know what happened to my last comment, but I wrote to say that this works! Thank you so much man, and I appreciate it!
rukfa
[View user's profile]

Joined: 2015-02-11
Posts: 5
Location: Sarajevo
Are there any known issues with working with Windows Services? I'm trying to implement the same thing using Windows Service application, and it won't copy files.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24553
Location: Prague, Czechia
rukfa wrote:
Are there any known issues with working with Windows Services? I'm trying to implement the same thing using Windows Service application, and it won't copy files.

No.

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate log file, set Session.SessionLogPath. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License