commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
I wanted to keep a backup of my company database server on my local homeserver. After I found maatkit to sync databases, everything except security seemed fine. SSH takes care of that part.
The important thing to note in this command, is the "-n" flag.
Once it is connected to the remote server by that ssh protocol,the mentioned command will start working on that server.
Of course you need to be able to access host A for this ;-)
Stop tormenting the poor animal cat!
Also you should not that you need a private key not protected by a passphrase on middlehost that grants you access to securehost..
middlehost allows ssh access from where you are but not securehost.
Use nice ssh piping to simulate scp through A => B => C
setting up the shell function if left as an exercise for the reader. ;-)
Agent forwarding should avoid password typing.
Useful to move many files (thousands or millions files) over ssh. Faster than scp because this way you save a lot of tcp connection establishments (syn/ack packets).
If using a fast lan (I have just tested gigabyte ethernet) it is faster to not compress the data so the command would be:
tar -cf - /home/user/test | ssh [email protected] 'cd /tmp; tar xf -'
I have a small embedded linux device that I wanted to use for sniffing my external network, but I didn't want to recompile/cross-compile snort for the embedded platform. So I used tcpdump over ssh to pass all the traffic as pcap data to a "normal" Linux system that then takes the pcap data and passes it to snort for processing.
Locally watch MySQL process list update every 5s on a remote host. While you watch pipe to a file. The file out put is messy though but hey at least you have a history of what you see.
Same as original just no $ at start
If you know the benefits of screen, then this might come in handy for you. Instead of ssh'ing into a machine and then running a screen command, this can all be done on one line instead. Just have the person on the machine your ssh'ing into run something like
screen -S debug
Then you would run
ssh -t [email protected] screen -x debug
and be attached to the same screen session.
This will launch and irssi session on your server. If it's not running, it will create the session. If it's running it'll connect to it and destroy any other connections. If compositing is available, the rxvt window will have transparency added. This window will also open maximized. Anything else this does should be easily figured out in the man pages.
Knock on ports to open a port to a service (ssh for example) and knock again to close the port. You have to install knockd.
See example config file below.
logfile = /var/log/knockd.log
sequence = 3000,4000,5000
seq_timeout = 5
command = /sbin/iptables -A INPUT -i eth0 -s %IP% -p tcp --dport 22 -j ACCEPT
tcpflags = syn
sequence = 5000,4000,3000
seq_timeout = 5
command = /sbin/iptables -D INPUT -i eth0 -s %IP% -p tcp --dport 22 -j ACCEPT
tcpflags = syn
Directly attach a remote screen session (saves a useless parent bash process)
put down the joint and rtfm :)
Redirects the contents of your clipboard through a pipe, to a remote machine via SSH.
Thankfully, the ssh command allows you to specify multiple tunnels through the same server in one command.
Remeber if you want a priviliged port on your machine, you must use root or sudo account.
If your firewall or proxy at your location prevents connection to a particular host or port, you can use ssh to tunnel to your home server and do it there instead.
more information: man sdiff
Run GUI apps on another machine remotely through SSH.
-C is for data compression and -X enables X11 forwarding.