You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Lyor Goldstein (Jira)" <ji...@apache.org> on 2022/07/28 17:19:00 UTC

[jira] [Commented] (SSHD-1283) Wanted to disable ssh commond while giving scp and sftp support

    [ https://issues.apache.org/jira/browse/SSHD-1283?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17572572#comment-17572572 ] 

Lyor Goldstein commented on SSHD-1283:
--------------------------------------

There are +3+ things to take care of if you want to disable remote command execution and/or interactive shell while leaving only SCP and SFTP active.

Before calling {{SshServer#start}}

# call {{SshServer#setCommandFactory(null)}}
# call {{SshServer#setShellFactory(null)}}
# create a +new+ {{ScpCommandFactory}} that overrides the methods below and use it instead of the default
{code:java}
    @Override
    public ShellFactory selectShellFactory(ChannelSession channelSession) throws IOException {
        return null;
    }
    @Override
    public Command createShell(ChannelSession channel) throws IOException {
        return null;
    }
{code}

In SSHD-1009 we introduced an {{ScpShell}} that provides a +limited+ set of commands in order to use {{WinSCP}} and this shell might be what is providing the interactive capabilities (provide you took care of the other 2 setups). +Note though:+ if you do as I suggested then you will +not+ be able to use {{WinSCP}} with SCP (only with SFTP) as it relies on a +combination+ of SHELL and SCP...

> Wanted to disable ssh commond while giving scp and sftp support
> ---------------------------------------------------------------
>
>                 Key: SSHD-1283
>                 URL: https://issues.apache.org/jira/browse/SSHD-1283
>             Project: MINA SSHD
>          Issue Type: Question
>            Reporter: Sandeep
>            Priority: Major
>         Attachments: SFTP.zip, image-2022-07-28-17-25-36-368.png
>
>
> Hi Team, 
> We have implemented sftp server where we are giving SFTP and SCP both support. 
> Both are working fine if we connected via winscp or any terminal client like putty etc.
>  
> But if we use ssh command *ssh <userName>@localhost -p <port>*
> then it goes to interactive mode and exposes the current program running directory to do all operations(screenshot shows dir command) (sftp is showing correct directory as C:/ ) 
>  
> !image-2022-07-28-17-25-36-368.png|width=462,height=485!
>  
> So just wanted to check if can we just disable the above ssh command and still we can use scp and sftp? any help appreciated. 
> May be this fix is causing the problem? : https://issues.apache.org/jira/browse/SSHD-1009,
> I have attached the sample code.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org