Monday, April 15, 2013

Useful IT commands

SSH
to connect to computer via ssh:
ssh username@host
to create tunnel

ssh username@host -L p1:h:p2

p1=local port (the port it is being directed to on local machine)
h=host machine, can be localhost(which will be remote machine) or machine accesible from original remote host(host)
p2=remote port, port on host machine(h) that is sending info

to be able to open up graphical applications on local computer

ssh -X username@host

to use ssh without needing a password:
first create an RSA key -

ssh-keygen

keep hitting enter for everything
will save key in ~/.ssh/
do this on both computers
then you need to send id_rsa.pub between computers. save in .ssh as authorized_keys
my preferred method (just one way, needs to be done on both)

cd ~/.ssh/
scp id_rsa.pub username@host:.
ssh username@host
cat id_rsa.pub >> ~/.ssh/authorized_keys

ARP
shows current/recent connections
arp -a

PING
sends packets (useful for checking network)
ping -c <#> <domain/ip>
-c for count without specific count will contiue until you tell it to stop

TRACEROUTE
traceroute <domain/ip>
will trace the route to specified destination and return ip's from each point along the way

WHOIS
whois <ip>
will return information about ip (like registration info)

NAT - to set up NAT on a gateway computer
sudo iptables -t nat -A POSTROUTING -o <network card:e.g. eth0> -j MASQUERADE
echo '1' | sudo tee /proc/sys/net/ipv4/ip_forward

DIG
shows dns servers, makes it possible to trace path one by one.

NMAP
nmap has various uses. my most recent = finding what other computers are on the network with me (and ip, or more specifically, just the ip)

nmap -sP 192.168.1.1-254

Worked great for me. you could also use

nmap -sP 192.168.1.1/24

These will show you the ip's that are up on your network. (well, on the 192.168.1.x network)

No comments:

Post a Comment