Created
March 3, 2012 09:19
-
-
Save leon/1965146 to your computer and use it in GitHub Desktop.
ssh-copy-rmate allows you to easily copy the remote script to your server using the same syntax as ssh-copy-id
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -r | |
# | |
# Usage: ssh-copy-rmate [--bash] [user@]machine | |
# | |
# Shell script to install rmate on the remove server so we can open shell scripts locally. | |
# Author: Leon Radley (http://github.com/leon) | |
URL="https://raw.github.com/avian/rmate/master/rmate" | |
if [ "$#" -gt 1 ] || [ "$1" = "-b" ] || [ "$1" = "--bash" ]; then | |
shift | |
URL="https://raw.github.com/aurora/rmate/master/rmate.sh" | |
fi | |
if [ "$#" -lt 1 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then | |
cat <<EOF | |
Usage: $0 [--bash] [user@]machine | |
# Install TextMate2 and enable rmate in the preferences | |
http://blog.macromates.com/2011/mate-and-rmate/ | |
# Setup ssh for easy access | |
edit ~/.ssh/config | |
# The automatic forwarding | |
RemoteForward 52698 localhost:52698 | |
# Standard user, so you can do ssh servername instead of root@servername | |
User root | |
# Custom aliases | |
Host myalias | |
HostName myserver.mydomain.com | |
User myuser | |
EOF | |
exit 1 | |
fi | |
wget --quiet -O - "${URL}" | ssh ${1%:} 'umask 077; test -d /usr/local/bin || mkdir -p /usr/local/bin; cat > /usr/local/bin/rmate; chmod a+rx /usr/local/bin/rmate' || exit 1 | |
cat <<EOF | |
Installation complete! | |
For more information run $0 --help | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment