4

In Nautilus it was possible to build up a ssh connection to a remote server via passphrase. Then you could bookmark the address and go there really fast. This still works in Nemo with Ubuntu 13.10.

But then, with a right click and using the option "open in a terminal" the user could open a terminal that would show a prompt of the remote server. So you could start to work there right away.

Using Nemo and not Nautilus anymore in Ubuntu 13.10 this doesn't seem to work anymore. I found out that I could use a script:

#!/bin/sh
gnome-terminal --execute /usr/bin/ssh user@myserver.net

But I would prefer to get back the old behaviour. Is that somehow possible?

2

You could create two actions in ~/.local/share/nemo/actions.

File remote_terminal1.nemo_action:

[Nemo Action]
Name=Open in remote terminal
Comment=Open current folder in remote terminal
Name[de]=Im entfernten Terminal öffnen
Comment[de]=Aktuellen Ordner im entfernten Terminal öffnen
Exec=<remote_terminal.py %F>
Icon-Name=terminal
Selection=none
Extensions=dir;
Dependencies=ssh;

File remote_terminal2.nemo_action:

[Nemo Action]
Name=Open in remote terminal
Comment=Open this folder in remote terminal
Name[de]=Im entfernten Terminal öffnen
Comment[de]=Diesen Ordner im entfernten Terminal öffnen
Exec=<remote_terminal.py %F>
Icon-Name=terminal
Selection=s
Extensions=dir;
Dependencies=ssh;

And finally a Python script remote_terminal.py (must be executable):

#!/usr/bin/env python2
# -*- coding: utf-8 -*-

import sys
import subprocess

path = sys.argv[1]

if '/sftp:' in path:
    sftp = path.split('/sftp:', 1)[1]
    settings = {}
    options, sep, settings['path'] = sftp.partition('/')
    for opt in options.split(','):
        name, sep, value = opt.partition('=')
        settings[name] = value

    cmd = ['gnome-terminal', '-e',
        'ssh %(user)s@%(host)s -t "cd /%(path)s && bash --login"' % settings]
else:
    cmd = ['gnome-terminal', '--working-directory', path]

subprocess.call(cmd)
1

While writing these lines I suffered a further break down with Nemo. Migrating to the 64-bit Version of Ubuntu 14.04 (Mate) I observed that the python scripts stopped working. I found that %F was denying to pass Paramaters any more. So I switched to %U (still working) and adapt the scripts to Bash (I am not a fan of Python, may be a personal taste):

#! /bin/bash


# $1 enthält den ersten Parameter

# Testweise Ausgabe aller übergebenen Parameter 
# echo $*
# exit

# der Regex schneidet "sftp://" ab und übergibt den Rest an $sftp
# sftp://root@debbie/var/databases -> root@debbie/var/databases
sftp=`echo $1 | sed 's#^[sftp://]*##'`
# echo $sftp

# Abschneiden des Domain
# root@debbie/var/databases -> root@debbie
domain=`echo $sftp | sed 's#\/.*##'`
# echo $domain

# Abschneiden des Pfades
# root@debbie/var/databases -> var/databases
path=`echo $sftp | sed 's#[^\/]*.##'`
# echo $path
# ssh='ssh '$domain' -t "cd /'$path' && bash --login"'
# echo $ssh

# Der übergebene Pfad startet vom Wurzelverzeichnis / 
gnome-terminal -e 'ssh '$domain' -t "cd /'$path' && bash --login"'

read exit 

The script does essentially the same as the python script but gives me a better grip on the things I want to do.

0

Using only bash, this is what worked for me in Linux Mint 19 and nemo 3.8.5:

remote_terminal1.action:

[Nemo Action]
Name=Open in remote terminal
Comment=Open current folder in remote terminal
Exec=<remote_terminal.sh %U>
Icon-Name=terminal
Selection=none
Extensions=dir;
Dependencies=ssh;

remote_terminal2.action:

[Nemo Action]
Name=Open in remote terminal
Comment=Open this folder in remote terminal
Exec=<remote_terminal.sh %U>
Icon-Name=terminal
Selection=s
Extensions=dir;
Dependencies=ssh;

remote_terminal.sh (don't forget to make it executable with chmod +x remote_terminal.sh):

#! /bin/bash

# Get host name
domain=`echo $1 | grep -Po "(?<=host=)[^,]*"`

if [ ${#domain} -eq 0 ]; then
    # Not an SSH directory, just open regular terminal
    gnome-terminal --working-directory="$1"
else
    # Get user name
    user=`echo $1 | grep -Po "(?<=user=)[^/]*"`

    # Get path
    path=`echo $1 | grep -Po "(?<=user="${user}").*"`
    if [ ${#path} -eq 0 ]; then
        path=/
    fi

    # Connect
    gnome-terminal -- ssh ${user}@${domain} -t "cd "${path}" && bash --login"
fi

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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