The files are automatically uncompressed when they reach the destination machine. This is a fast way to backup your server to your local computer while it's running (shutting down services is recommended). A file named "exclude.txt" is needed at /tmp/ containing the following : /dev/* /media/* /mnt/* /proc/* /sys/* /tmp/* /home/*/.local/share/Trash /home/*/.gvfs /home/*/.cache /home/*/.thumbnails /etc/fstab /lib/modules/*/volatile/.mounted /var/run/* /var/lock/* /var/tmp/* /var/cache/apt/archives/* /lost+found/* Show Sample Output
Useful, when you need to backup/copy/sync a folder over ssh with a non standard port number
Given a hosts list, ssh one by one and echo its name only if 'processname' is not running. Show Sample Output
client:
nc localhost 9876
If you are on machine 1 and want to ssh into machine 3, but you can only do so from machine 2, this will do it all in one go. Note that once you are on machine 3 and exit () it will take you directly back to machine 1
Replace servername with your user. And make sure you have generated / copied your rsa_pub key to the remote server, or you will be asked for a password which will stuff up the output to wireshark.
This command telnet and and looks for a line starting with "SSH" - works for OpenSSH since the SSH banner is something like "SSH-2.0-OpenSSH_6.0p1 Debian-4+deb7u3". Then it triggers an action accordingly.
It can be packed as a script file to echo 0/1 indicating the SSH service availability:
if [[ "$(sleep 1 | telnet -c <host> <port> 2>&1 | grep '^SSH')" == SSH* ]]; then echo 1; else echo 0; fi;
Alternative uses:
Trigger an action when server is UP (using &&):
[[ "$(sleep 1 | telnet -c <host> <port> 2>&1 | grep '^SSH')" == SSH* ]] && <command when up>
Trigger an action when server is DOWN (using ||):
[[ "$(sleep 1 | telnet -c <host> <port> 2>&1 | grep '^SSH')" == SSH* ]] || <command when down>
Generating ssh key then need to copy public key in to /root/.ssh/authorized_keys
Creates socket from your local computer to remote server using SSH, easy to penetrate firewall if SSH is allowed.
Commandline for windows + cygwin with specific interface and resolved ip.
There's no need to make this complicated. The command already exist in the form of ssh-copy-id.
first line is the speed the uncompressed data is read, second line is the compressed data sent over ssh. change sdb to your target drive/partition to be backed up. change pbzip -c1 to suit your compression. and ssh to your target file. don't forget to run zerofree/fstrim first! Show Sample Output
untar in place with out creating a temporary file
Overwrites remote file without asking! Uses HTTPS proxy that supports CONNECT. Actually uses SSH and not SFTP to upload the file.
This version won't reconnect if you exit the ssh connection with a non-zero exit code. ConnectTimeout and sleep values knobs for how long to wait for each retry.
Create a secure tunnelled connection for access to a remote MySQL database. For example, connect with MySQL Workbench to root@127.0.0.1:13306. Show Sample Output
Transfer files with rsync over ssh on a non-standard port, showing a progress bar and resuming partial transfers.
If you work in an environment, where some ssh hosts change regularly this might be handy...
Easily removes line #2 in ~/.ssh/known_hosts. Show Sample Output
Mac install ssh-copy-id
From there on out, you would upload keys to a server like this:
(make sure to double quote the full path to your key)
ssh-copy-id -i "/PATH/TO/YOUR/PRIVATE/KEY" username@server
or, if your SSH server uses a different port (often, they will require that the port be '2222' or some other nonsense:
(note the double quotes on *both* the "/path/to/key" and "user@server -pXXXX"):
ssh-copy-id -i "/PATH/TO/YOUR/PRIVATE/KEY" "username@server -pXXXX"
...where XXXX is the ssh port on that server
http://github.com/c3w/ash . a Ruby SSH helper script . reads a JSON config file to read host, FQDN, user, port, tunnel options . changes OSX Terminal profiles based on host 'type' USAGE: put 'ash' ruby script in your PATH modify and copy ashrc-dist to ~/.ashrc configure OSX Terminal profiles, such as "webserver", "development", etc run "ash myhostname" and away you go! v.2 will re-attach to a 'screen' named in your ~/.ashrc Show Sample Output
ssh compresion -C option ... on slow connection VNC performs better but in local LAN native secure X protocol is an option Show Sample Output
This command adds your pem key to SSH so that you no longer have to manually specify it when connecting to EC2 instances. # you can do this: ssh ec2-instance.amazonaws.com # instead of this: ssh -i ~/.ssh/KEY_PAIR_NAME.pem ec2-instance.amazonaws.com Show Sample Output
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: