Server refused to start a shell/command

Advertisement

rukfa
Joined:
Posts:
5
Location:
Sarajevo

Server refused to start a shell/command

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");
...
}

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,454
Location:
Prague, Czechia

Re: Server refused to start a shell/command

You probably want to do session.GetFiles("folder/*","folder\",true,null). This won't delete the folder, just the files in it.

Reply with quote

rukfa

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.

Reply with quote

Advertisement

rukfa

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.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,454
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.

Reply with quote

Advertisement

You can post new topics in this forum