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