Commit 064a7984 authored by Philip Linghammar's avatar Philip Linghammar
Browse files

Updates transfering_files.md

Auto commit by GitBook Editor
parent 22e5515d
Loading
Loading
Loading
Loading
+31 −9
Original line number Diff line number Diff line
@@ -69,6 +69,25 @@ nc -l 1234 > file.sh
```



## Socat

Server receiving file:

```
server$ socat -u TCP-LISTEN:9876,reuseaddr OPEN:out.txt,creat && cat out.txt
client$ socat -u FILE:test.txt TCP:127.0.0.1:9876
```

Server sending file:

```
server$ socat -u FILE:test.dat TCP-LISTEN:9876,reuseaddr
client$ socat -u TCP:127.0.0.1:9876 OPEN:out.dat,creat
```



## With php

```
@@ -111,22 +130,22 @@ ssh-keygen -t rsa -C "your_email@example.com"

then you enter a name for the key.

Enter file in which to save the key (/root/.ssh/id_rsa): nameOfMyKey
Enter passphrase (empty for no passphrase): 
Enter file in which to save the key \(/root/.ssh/id\_rsa\): nameOfMyKey  
Enter passphrase \(empty for no passphrase\):   
Enter same passphrase again:

This will create two files, one called `nameOfMyKey` and another called `nameOfMyKey_pub`. The one with the `_pub` is of course your public key. And the other key is your private.

2. Add your public key to authorized_keys.
1. Add your public key to authorized\_keys.

Now you copy the content of `nameOfMyKey_pub`.   
On the compromised machine you go to `~/.ssh` and then run add the public key to the file authorized_keys. Like this 
On the compromised machine you go to `~/.ssh` and then run add the public key to the file authorized\_keys. Like this

```bash
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQqlhJKYtL/r9655iwp5TiUM9Khp2DJtsJVW3t5qU765wR5Ni+ALEZYwqxHPNYS/kZ4Vdv..." > authorized_keys
```

3. Log in.
1. Log in.

Now you should be all set to log in using your private key. Like this

@@ -145,3 +164,6 @@ scp /path/to/source/file.ext username@192.168.1.101:/path/to/destination/file.ex
# Copy a directory:
scp -r /path/to/source/dir username@192.168.1.101:/path/to/destination
```