Get and send a file with SCP using options - scp

How to write scp user#url:/tmp/foo ./ with options instead of one-liner ?
I tried this, but unsuccessfully:
scp -l user url /tmp/foo ./

Send file
scp -o user=myuser foo.txt myserver:/my/folder
Get file
scp -o user=myuser myserver:/my/folder/foo.txt ./

Related

How do I use SSH on Laradock?

I'd like to set up SSH with my Laradock workspace container so I can deploy to git.
Inside the workspace folder, there are keypairs insecure_id_rsa and insecure_id_rsa.pub.
Obviously I don't want to use what comes in the repository, but there are no instructions beyond connecting inside the workspace.
Am I supposed to generate my own keys and have them in my workspace folder?
in the DockerFile:
###########################################################################
# ssh:
###########################################################################
ARG INSTALL_WORKSPACE_SSH=false
COPY insecure_id_rsa /tmp/id_rsa
COPY insecure_id_rsa.pub /tmp/id_rsa.pub
RUN if [ ${INSTALL_WORKSPACE_SSH} = true ]; then \
rm -f /etc/service/sshd/down && \
cat /tmp/id_rsa.pub >> /root/.ssh/authorized_keys \
&& cat /tmp/id_rsa.pub >> /root/.ssh/id_rsa.pub \
&& cat /tmp/id_rsa >> /root/.ssh/id_rsa \
&& rm -f /tmp/id_rsa* \
&& chmod 644 /root/.ssh/authorized_keys /root/.ssh/id_rsa.pub \
&& chmod 400 /root/.ssh/id_rsa \
&& cp -rf /root/.ssh /home/laradock \
&& chown -R laradock:laradock /home/laradock/.ssh \
;fi
How do I set up a secure SSH connection to Laradock to use on Github?
I can connect in my workspace doing ssh root#localhost. I just don't understand what's required to have my own keys inside the container and how to do it securely.
Should I make a new key with putty and replace the insecure keys?
Edit: so i can run ssh-keygen on my container and get new keypairs. I can deploy on github fine with them.
But of course, when my docker restarts, these files are no longer there and get overwritten by the config above.
So is it safe to put my actual keys in a laradock folder?
Edit: I ended up copying what ssh-keygen generated in the .ssh folder and pasting into the files that get copied over when my containers run. this of course works fine, but I'm just not sure this is the best way to go about things. especially if you want to keep the repo up to date with what laradock is doing
Can you copy the generated ssh keys to the laradock folder (and rename them to insecure_id_rsa and insecure_id_rsa.pub) then laradock will copy them across each time?
Or set INSTALL_WORKSPACE_SSH=false after it is set up so it doesn't overwrite the keys?

How to enable sshpass output to console

Using scp and interactively entering the password the file copy progress is sent to the console but there is no console output when using sshpass in a script to scp files.
$ sshpass -p [password] scp [file] root#[ip]:/[dir]
It seems sshpass is suppressing or hiding the console output of scp. Is there a way to enable the sshpass scp output to console?
After
sudo apt-get install expect
the file send-files.exp works as desired:
#!/usr/bin/expect -f
spawn scp -r $FILES $DEST
match_max 100000
expect "*?assword:*"
send -- "12345\r"
expect eof
Not exactly what was desired, but better than silence:
SSHPASS="12345" sshpass -e scp -v -r $FILES $DEST 2>&1 | grep -v debug1
Note that -e is considered a bit safer than -p.
Output:
Executing: program /usr/bin/ssh host servername, user username, command scp -v -t /src/path/dst_file.txt
OpenSSH_6.6.1, OpenSSL 1.0.1i-fips 6 Aug 2014
Authenticated to servername ([10.11.12.13]:22).
Sending file modes: C0600 590493 src_file.txt
Sink: C0600 590493 src_file.txt
Transferred: sent 594696, received 2600 bytes, in 0.1 seconds
Bytes per second: sent 8920671.8, received 39001.0
In this way:
output=$(sshpass -p $PASSWD scp -v $filename root#192.168.8.1:/root 2>&1)
echo "Output = $output"
you redirect the console output in variable output.
Or, if you only want to see the console output of scp command, you should add only -v command in your ssh pass cmd:
sshpass -p $PASSWD scp -v $filename root#192.168.8.1:/root

Open PDF found with volatility

my task is to analyze a memory dump. I've found the location of a PDF-File and I want to analyze it with virustotal. But I can't figure out how to "download" it from the memory dump.
I've already tried it with this command:
python vol.py -f img.vmem dumpfiles -r pdf$ -i --name -D dumpfiles/
But in my dumpfile-directory there is just a .vacb file which is not a valid pdf.
I think you may have missed a command line argumenet from your command:
python vol.py -f img.vmem dumpfiles -r pdf$ -i --name -D dumpfiles/
If you are not getting a .dat file in your output folder you can add -u:
-u, --unsafe Relax safety constraints for more data
Can't test this with out access to the dump but you should be able to rename the .dat file created to .pdf.
So it should look something like this:
python vol.py -f img.vmem dumpfiles -r pdf$ -i --name -D dumpfiles/ -u
You can check out the documentation on the commands here
VACB is "virtual address control block". Your output type seems to be wrong.
Try something like:
$ python vol.py -f img.vmem dumpfiles --output=pdf --output-file=bla.pdf --profile=[your profile] -D dumpfiles/
or check out the cheat sheet: here

Count number of files in directory then scp transfer a certain range such as 21404-42806

I found the number of files in /dev/shm/split/1/ to be 42806 using:
/bin/ls -lU /dev/shm/split/1/ | wc -l
What I can't seem to find anywhere online is how to select a certain range, say from 21404-42806, and use scp to securely copy those files. Then, for management purposes, I would like to move the files I copied to another folder, say /dev/shm/split/2/.
How do I do that using CentOS?
I tried:
sudo chmod 400 ~/emails/name.pem ; ls -1 /dev/shm/split/1/ | sed -n '21443,42806p' | xargs -i scp -i ~/emails/name.pem {} root#ipaddress:/dev/shm/split/2/
This produced:
no such file or directory
errors on all of the files...
ls itself lists files relative to the directory you give. This means your ls prints the filenames in the directory, but later on, scp doesn't have the path to them. You can fix this two ways:
Give the path to scp:
ls -1 /dev/shm/split/1/ | sed -n '21443,42806p' | xargs -i \
scp -i ~/emails/name.pem /dev/shm/split/1/{} root#ipaddress:/dev/shm/split/2/
Change to that directory and it will work:
cd /dev/shm/split/1/; ls -1 | sed -n '21443,42806p' | xargs -i \
scp -i ~/emails/name.pem {} root#ipaddress:/dev/shm/split/2/

How to wget .mp4 files on Apache Directory

I want to download all .mp4 files from a "Index of" page using wget.
The target directory is http://ia600409.us.archive.org/27/items/MIT18.01JF07/
I've tried some commands (which I copied and pasted from websites), but they don't seem to work.
e.g.:
wget -r -l0 -nd --no-parent -A .mp4 -R ".*"
http://ia600409.us.archive.org/27/items/MIT18.01JF07/
Btw, I think the directory is Apache.
wget -e robots=off -r -nd -np -A mp4 http://ia600409.us.archive.org/27/items/MIT18.01JF07