LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 11-27-2008, 10:22 AM   #1
oudoubah
LQ Newbie
 
Registered: Oct 2005
Location: France
Distribution: Arch
Posts: 23

Rep: Reputation: 0
ssh : allowing only scp and 1 command


Hi,

I try to configure ssh for allowing only 1 command and scp.

I've changed ~/.ssh/authorized_key like this :
Code:
command="/tmp/myscript" ....
Here is /tmp/myscript :
Code:
#!/bin/sh

exec 1>&2

echo "$SSH_ORIGINAL_COMMAND" | grep -q '^scp'
if [ $? -eq 0 ] ; then
        echo "scp demandé"
        params="$(echo $SSH_ORIGINAL_COMMAND | cut -d ' ' -f 2-)"
        echo "Execution de scp $params"
        exec scp -v $params
else
        ls /tmp | wc -l
fi
The scp server runs, but there is no transfert :-/

I tryed to apply this http://www.snailbook.com/faq/restricted-scp.auto.html to make my own wrapper, but what i've made doesn't work (i prefer using bash script).

How is it possible to allow only scp and 1 command?
 
Old 11-27-2008, 12:07 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
Hi,

I have half an answer and a suggestion for a different approach.

Half the answer first: There is a program that's called scponly, which disables normal ssh logins and only permits the use of scp (hence scponly). But this only solves half your problem, I would not know how to combine scponly with the '1 specific command' only request.

If you are interested in scponly, feed your favorite search engine. Here are 2 links to get you going:

scponly - wiki
scponly - freshmeat

Maybe you can use a different approach: You could consider creating a specific account that has a script as a 'shell' instead of the standard bash/ksh/... shell. When one logs into that account the script, which could be anything from a single command to a menu with multiple things, is executed and the user is logged out again afterwards.

Hope this gets you going again.
 
Old 11-28-2008, 04:45 PM   #3
oudoubah
LQ Newbie
 
Registered: Oct 2005
Location: France
Distribution: Arch
Posts: 23

Original Poster
Rep: Reputation: 0
The script below works to allow scp and other restricted commands :

Code:
#!/bin/sh

echo $SSH_ORIGINAL_COMMAND | grep '^scp'
if [ $? -eq 0 ] ; then
   ${SSH_ORIGINAL_COMMAND}
else
   echo "ssh command to execute : ${SSH_ORIGINAL_COMMAND}"
fi
exit 0
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to simulate scp command using ssh? vickylife Linux - Newbie 3 11-18-2008 06:22 AM
How to use EXPECT command to scp or ssh? thefountainhead100 Linux - Software 6 03-28-2008 07:41 PM
Translating windows pscp command to linux scp command help robward Linux - General 2 01-17-2008 07:02 AM
Is Allowing SSH Safe? Optimistic Linux - Security 10 03-21-2005 02:58 PM
Allowing for incoming ssh InsaneBob Linux - Software 11 04-12-2003 02:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 10:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration