1

At my university, I ssh into a ubuntu computing cluster to run software such as matlab and mathematica. I like to keep the files that I create on my own (ubuntu) machine so that (1) they are all in one place, and (2) I can use software on my local machine to edit the files.

My current approach is to 1) Login to the remote machine 2) Look up my local ip address with ifconfig 3) Mount the directories I want to work with on the remote machine using sshfs manually typing in my local ip address

This works pretty well, but I was wondering is there a way to automate this, or a better approach? i.e. can I make certain directories like /home/user/Classes automatically mount on the remote machine without hassling with my ip address?

2 Answers 2

0

First thing you wanna do if you haven't already is make it so you can login without a password.

http://www.linuxproblem.org/art_9.html

Second thing you wanna do is just run a script on the user login

you can do this several ways the easiest way is putting the command in a .bashrc or .profile file

The first line makes sure it is running only in ssh terminal you can remove that if it doesn't matter.

if [ -n "$SSH_TTY" ]; then
    $HOME/bin/run_ssh_login_script
fi

Of course you can get creative and detect connecting ip address and the login user details. Also a cool script I found for doing the connecting http://taggedzi.com/articles/display/bash-shell-script-to-mount-remote-systems-using-sshfs

0
0

As a word of caution, you should ensure that authentication between machines is one way. This means that you should access the server from your laptop, but you shouldn't allow the server to access the laptop in the same way. It may not be obvious here, but with larger networks, this security problem becomes more evident.

Why not mount the remote directories locally, and then ssh into the machine (sshfs, fuse, fstab)? Is it because the files on the laptop are updated, and those updated version are needed on the remote machine (rsync)? After the server runs, are the files updated and you need to then bring those processed copies down? If you provided an example workflow, including the files, that information would be helpful to answer your question.

You say you want to be able to edit the files using local software, so you can set up sshfs on your laptop to connect to the remote server, so long as you're okay with not editing the files while not having access to the server.

Another option is to use rsync, which might be a better solution if the source of truth, or updated copies swap between the laptop and server. You would be able to sync them both, and tell rysnc which system is the most up-to-date.


It sounds to me like you've just overthought this a bit, and instead of logging into the server and mounting your directories from the laptop, go ahead and mount those directories from the server to the laptop, and then ssh into the system.

To make all of this easier, look into setting up .ssh/config with PubKeyAuthentication.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .