Last active
February 24, 2017 17:41
-
-
Save alexstaravoitau/e7860838e769dfed835418b38d8e069c to your computer and use it in GitHub Desktop.
Routines for SSH-ing to remote machine, mount its file system and attach to a persistent tmux session. Check out my post about building and configuring my remote machine: http://navoshta.com/meet-fenton/
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/bash | |
# Connects to remote server, mounts its file system or attaches to a tmux session. | |
USER="tom" | |
SERVER="[email protected]:8989" | |
LOCAL_KEY_PATH="/Users/tom/ssh_keys/key" | |
LOCAL_MOUNT_PATH="/Users/tom/mount/" | |
if [ $# -eq 0 ]; then | |
echo "Connecting to Fenton." | |
ssh $SERVER | |
fi | |
while test $# -gt 0; do | |
case "$1" in | |
jesus|-jesus|--jesus) | |
shift | |
if [ $1 == 'christ' ]; then | |
echo "FENTON! FENTON, JESUS CHRIST! FENTON!!!" | |
open 'https://www.youtube.com/watch?v=3GRSbr0EYYU' | |
fi | |
shift | |
;; | |
fs|-fs|--fs) | |
echo "Mounting Fenton file system." | |
umount $SERVER:/ &> /dev/null | |
sshfs -o delay_connect,reconnect,ServerAliveInterval=5,ServerAliveCountMax=3,allow_other,defer_permissions,IdentityFile=$LOCAL_KEY_PATH $SERVER:/ $LOCAL_MOUNT_PATH | |
shift | |
;; | |
jn|-jn|--jn) | |
echo "Attaching to Jupyter Notebook session on Fenton." | |
ssh -t $SERVER 'tmux -CC attach' | |
shift | |
;; | |
*) | |
break | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment