Archive for February, 2009

Alternative ways to transfer files when you do not have ftp or sftp server available

Very often I find myself having to transfer files to remote machines that do not have ftp or sftp server running.

Here are a few methods that I use in those cases:

  1. Using scp:

    The secure copy protocol and command are part of ssh. I am assuming that you have Linux or Unix boxes that you are dealing with. If any of them are Windows computers you need to install ssh servers and clients respectively.
    The command looks like this:

    scp source_file user@IP:path

    For example, if I wanted to copy the 1.txt file to the /tmp directory on the remote computer with ip address of 24.155.21.105 as root, I would do:

    scp 1.txt root@24.155.21.105:/tmp/
  2. Using ssh:
    cat source_file  | ssh user@IP -c ‘cd /target_dir ; cat > target_file’

    For example if I wanted to transfer my local file 1.txt to the same remote host and save it in the /tmp directory under the name of 2.txt, I would do:

    cat 1.txt  | ssh root@24.155.21.105 -c ‘cd /tmp ; cat > 2.txt’
  3. Using netcat:

    First you need to start a netcat server on your local machine to serve the files:

    cat source_file | nc -l port_number

    Then on the computer receiving the file you do:

    nc IP port_number > target_file

    For example, if I wanted to send the same file 1.txt to the same remote computer and save it as 2.txt over port 3030 (you can chose any port, but make sure it is over 1024), I would do:

    On the local computer:

    cat 1.txt | nc -l 3030

    On the remote computer, receive the file by specifying the IP address of the machine sending the file:

    nc 122.45.62.10 3030 > 2.txt

    Again, note here that the ip address specified is of the computer sending the file (unlike the previous examples with scp and ssh).

Monday, February 23rd, 2009 Linux, Networking No Comments

Find out the subdomains of a given domain name with dig

First,  find out the name server(s) for the domain name in question:

dig wikipedia.com

Look under the “AUTHORITY SECTION”:

;; AUTHORITY SECTION:
wikipedia.com.        163475    IN    NS    ns2.wikimedia.org.
wikipedia.com.        163475    IN    NS    ns1.wikimedia.org.
wikipedia.com.        163475    IN    NS    ns0.wikimedia.org.

In this case wikipedia.com has 3 name servers: ns0.wikimedia.org, ns1.wikimedia.org and ns2.wikimedia.org. Now we can query one of these three servers for the subdomains of wikipedia.com:

dig @ns1.wikimedia.org wikipedia.com axfr

Here is what we get back (the list is rather long, so I have truncated it quite a bit);

; <<>> DiG 9.5.0-P2 <<>> @ns1.wikimedia.org wikipedia.com axfr
; (1 server found)
;; global options:  printcmd
wikipedia.com.        3600    IN    A    208.80.152.2
wikipedia.com.        86400    IN    NS    ns0.wikimedia.org.
wikipedia.com.        86400    IN    NS    ns1.wikimedia.org.
wikipedia.com.        86400    IN    NS    ns2.wikimedia.org.
wikipedia.com.        3600    IN    MX    50 lists.wikimedia.org.
wikipedia.com.        3600    IN    MX    10 mchenry.wikimedia.org.
aa.wikipedia.com.    3600    IN    CNAME    rr.wikimedia.org.
aa.mobile.wikipedia.com. 3600    IN    CNAME    rr.wikimedia.org.
aa.wap.wikipedia.com.    3600    IN    CNAME    rr.wikimedia.org.
ab.wikipedia.com.    3600    IN    CNAME    rr.wikimedia.org.
ab.mobile.wikipedia.com. 3600    IN    CNAME    rr.wikimedia.org.
ab.wap.wikipedia.com.    3600    IN    CNAME    rr.wikimedia.org.
...
...
...

Note: Not all dns servers will allow axfr protocol queiries. Those will return “Transfer failed”.

Sunday, February 8th, 2009 Linux, Networking 5 Comments

Search

 

Archive

February 2009
M T W T F S S
« Jan   Mar »
 1
2345678
9101112131415
16171819202122
232425262728  

Other