Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a file on another Ubuntu machine. I want to access it from my machine on my LAN. I don't want to go into Nautilus to mount the share first and then browse to the file. I want a command that will connect via SSH automatically (by mounting its share if not already or however) and open that file on my machine in the associated program (assume I do have that program install on my machine).

Any simple way to do this? I will be putting this command into a launcher so I can just double-click it.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

I assume you have sshfs set up ;)

#!/bin/bash

# Mount your sshfs
sshfs your_server:/sshfs_share /media/sshfs_share

#Use zenity to ask what file to open
file=$(zenity --entry --text "What file?")

# Or use a zenity file chooser
file=$(zenity --file-selection --title="Select a File)

# Open a file
gedit $file

For options with zenity, see zenity by example or man zenity

You can certainly elaborate on the script, adding error checking, check the existence of the file , etc, but that will get a good start.

share|improve this answer
    
See also sshfs. However, I think the instructions there on creating the "fuse" group and adding the user to it are no longer current, as I believe the "fuse" group is now included by default in Ubuntu, and regular users are members by default. –  bgvaughan Dec 15 '11 at 21:39
    
The script you have made looks very good, thanks. Is there a way to access the remote file via SSH without mounting the share? Lets assume the file is a text file, and I want to open it with gedit on my local machine. Or alternatively, if it must mount the share, can it avoid asking me for the remote server's password? –  nLinked Dec 17 '11 at 17:08
    
You can edit files remotely with vim, gvim or cream for a graphical interface. If you do not want to enter a password, use a ssh key and ssh agent. vim scp://user@server//path/to/document vim will open, there will be a short pause while it makes the connection, and then you will be asked to enter your password. See also linuxblog.pansapiens.com/2008/07/13/… and thecodecentral.com/2010/04/02/… If you are connecting from windows, you can do this with winscp –  bodhi.zazen Dec 17 '11 at 17:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.