0

For various reasons, I need to allow only one SSH connection to a server for a specificuser at a time, and when they log in, a command needs to be executed right away, limiting them in what they can do.

I thus created a script /usr/local/bin/limit-sshd (based on this question and answer) which is executed when an SSH connection is established (using ForceCommand in /etc/ssh/sshd_config) and which, very simplified, looks like this

#!/bin/bash
if [[ $USER == specificuser ]]
then
    /run/this/command
else
    ...
fi

The use case for which this was created now includes file transfer to the server which you could typically achieve using an SFTP client such as pscp.

I am on a Windows machine using PuTTY and have a configuration for the server that I need to access; the configuration includes the sharing of the SSH connection. I can log in to the machine. On my Windows command line I then tried

pscp -load configuration c:\path\to\file_to_copy specificuser@<server IP>:/path/to/destination

This works with a user that does not have the limitations described above, but fails with

FATAL ERROR: Received unexpected end-of-file from server

I'm assuming this is due to the fact that there is some command passed via the SSH connection that the server cannot handle because of how I set things up above.

(How) can I enable file transfers over this connection?

4
  • Please describe how you attempted to "transfer a file using the existing SSH connection" with pscp Commented Oct 21, 2020 at 11:15
  • @steeldriver edited the question to make my use of pscp clearer Commented Oct 21, 2020 at 11:51
  • Thanks - what I was really interested in was the configuration - I guess you are doing this Sharing an SSH connection between PuTTY tools, is that correct? Can you give us any information about what /run/this/command does? Commented Oct 21, 2020 at 12:31
  • @steeldriver Yes, I am sharing the connection. /run/this/command is a script that starts a Docker container inside which the specificuser can work, and which will be deleted after the user exits the container. The user needs to be able to load files from his own machine onto the server/into the container, ideally without a workaround like a Git repo or an Artifactory. Commented Oct 21, 2020 at 12:41

0

You must log in to answer this question.

Browse other questions tagged .