1. Add the public key to ~/.ssh/authorized_keys with the force command (using python script as an example):
COMMAND="mysshcmd.py",FROM="192.168.1.108",NO-AGENT-FORWARDING,NO-PORT-FORWARDING,NO-PTY,NO-USER-RC,NO-X11-FORWARDING ssh-rsa AAAAB3N......
2. On the client side with the private key, run the scp command to copy a directory:
$ scp -o StrictHostKeyChecking=no -r . username@hostname:/path/to/destination
3. In the file mysshcmd.py on the server side, add the code to handle the scp copying:
origCommandParm = os.environ['SSH_ORIGINAL_COMMAND']
origCommandParmArray = origCommandParm.split()
commandName = origCommandParmArray[0]
if commandName == "scp" :
destination = origCommandParmArra[3]
cpCommand = "scp -r -d -t " + destination
os.system(cpCommand)
Wednesday, May 22, 2019
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment