tramp mode will not work (ssh cannot resolve hostname)? - emacs

Earlier this week I tried ssh'ing into my lab machine (as I do very frequently) via tramp mode (ubuntu 14.04) and now it seems to not work out of the blue. I have tried checking all folder permissions, that ssh actually works (in terminal, even nested in emacs). However, it still will not connect me. I see the connection in my .ssh file so I am not sure what the issue is. Any ideas? This is killing my productivity since I would much rather tramp in vs git everything.
######### from C-x C-f ssh:user#host...etc (which has always worked in the past) #######
ssh: Could not resolve hostname ssh: Name or service not known
########## from *Messages buffer* #####################
Tramp: Opening connection for ssh using scp...
Tramp: Sending command `exec ssh -e none ssh'
Tramp: Waiting for prompts from remote shell
Tramp: Sending command `exec ssh -e none ssh'
Tramp: Opening connection for ssh using scp...done
byte-code: Process died
side note: I did start having pop-ups w/ system program problem detected but the ONLY thing in the /var/crash folder is a virtual box issue so I cant imagine that could be it. (Can I purge emacs and grab my config again and solve it that way?)

The error message clearly indicates that you are doing C-x C-f /ssh:user#host/path/to/file. A colon is missing after host. Pls open this like C-x C-f /ssh:user#host:/path/to/file.

Related

tramp ssh: Waiting for prompts from remote shell

I have been using emacs with tramp for a few weeks now to ssh into a server and edit some files. I do this by C-x C-f /ssh:username#server.com. Suddenly this has stopped working. I am getting "Waiting for prompts from remote shell problem" message.
However, If I don't provide a username (C-x C-f /ssh:server.com) then the connection seems to get established.
I am running emacs 24 using cygwin. How can I get this connection to work again?
There is one relatively common reason (at least on Windows/Cygwin platform): the ssh process started by tramp gets somehow stuck and unresponsive.
On my current desktop this happens once every month or so.
Just kill any ssh processes, either from your favourite cygwin terminal (with kill -9) or from your Windows task manager. This gets everything working again.
I have never encountered this problem on Linux, only on Windows/Cygwin.

How to use tramp with corkscrew to access remote clusters?

My computer network is closed to ssh to external machines (outside the network) through port 22. I have a round about by tunneling ssh through http by employing cockscrew. I modified my config file in the following fashion
Host EXTERNAL-HOSTNAME
ControlMaster auto
ControlPath ~/.ssh/%r#%h:%p
ServerAliveCountMax=30
ServerAliveInterval=5
ProxyCommand corkscrew LOCAL-PROXYNAME PROXY-PORT-NO %h %p
How can I now use tramp to access the files in the remote cluster? The regular command /ssh:username#EXTERNAL-HOSTNAME fails to open the file.
UPDATE 1:
My proxy does not use the default 8080 port but a different port number. So using
/tunnel:PROXY-HOSTNAME PROXY-PORT-NO | ssh:USERNAME#EXTERNAL-HOSTNAME:~/
gave me the following error
Tramp: Opening connection for tunnel using scp... Tramp: Sending
command exec ssh -o
ControlPath=/var/folders/k5/r4f1q8j90y345rsz_9skc7y48q0jr6/T/tramp.15685eSq.%r#%h:%p
-o ControlMaster=auto -o ControlPersist=no -e none tunnel' Tramp: Waiting for prompts from remote shell... Tramp failed to connect. If
this happens repeatedly, try
M-x tramp-cleanup-this-connection' Tramp: Waiting for prompts from remote shell...failed Tramp: Opening connection for tunnel using
scp...failed Use M-x make-directory RET RET to create the directory
and its parents
Tramp: Checking `vc-registered' for /tunnel:PROXY-HOSTNAME
PROXY-PORT-NO | ssh:USERNAME#EXTERNAL-HOSTNAME:~/...failed Use M-x
make-directory RET RET to create the directory and its parents Mark
set
UPDATE 2:
It worked. The only problem was I was not entering the port-no correctly. Now I just used
/tunnel:PROXY-HOSTNAME#PROXY-PORT-NO|ssh:USERNAME#EXTERNAL-HOSTNAME:~/
and it worked.
I don't know corkscrew so I cannot answer for this. However, Tramp is able to tunnel http by its own. Try to open /tunnel:LOCAL-PROXYNAME|ssh:username#EXTERNAL-HOSTNAME. The proxy command shall be removed from your ssh config, of course.

Emacs 24.3.1 TRAMP hangs on opening file

I am running graphical Emacs 24.3.1 (this problem exists when using the console version as well) on Arch Linux. I am trying to use TRAMP to open files on a remote Fedora system by SSH with a private key which requires a password. Authentication works fine, and so does the listing of files. When I do try to open a file, my Emacs session hangs with "Tramp: Inserting `/{filename I'm trying to open}' ...done". It is not possible to abort with ESC ESC ESC or C-g. Does anyone have a solution to this?
Emacs 24 normally works very well with Tramp. What you might need is ControlMasterAuto in your .ssh/config file. This will ensure that the ssh connection information passes seamlessly to Emacs. This will also ensure that you only need to login once in a terminal and use multiple emacs frames in tramp mode. I have detailed the following steps
(1) Go to your .ssh/config file and add the following options
Host <hostname>
ControlMaster auto
ControlPath ~/.ssh/%r#%h:%p
ServerAliveCountMax=30
ServerAliveInterval=5
(2) Now login to the remote host through terminal.
(3) Open emacs frame and try opening the remote files through tramp (/ssh:). You must be able to connect to the remote host.
The above steps should work even for a two level authentication (using a rsa key +password).
This thread is old - however, a very similar problem on my FC22 laptop (tramp hanging when trying to type a colon following /su in the minibuffer) appears to be fixed by commenting the ::1 line in /etc/hosts.

Tramp mode in emacs using ssh config

I think this is very basic question in using tramp, but it doesn't work for me.
I have my ~/.ssh/config file that points to my amazon ec2 machine
Host amazon
Hostname xxxx.amazonaws.com
Port yyy
User me
IdentityFile ~/.ssh/ubuntu
ForwardAgent yes
I can easily do ssh amazon from my terminal and I go to amazon ec2 (so my config is right), but in emacs
I do:
C-x C-f /ssh1:amazon:
I always get this error
In Aquamacs:
Process *tramp/ssh1 amz* exited abnormally with code 255
In Emacs:
tramp: Opening connection at amz using ssh1...
tramp: Waiting for prompts from remote shell
tramp: Waiting 60s for prompt from remote shell
tramp-process-actions: Login failed
I also have other ssh configurations that they ssh to my virtual boxes on my local machine and they have the same problem.
I really appreciate any help.
One thing that's worth trying is using the sshx connection method. That makes tramp try to avoid any non-standard shell configuration on the remote host.
Like this:
C-x C-f /sshx:amazon:
The tramp method ssh1 forces ssh to be run in ssh v1 protocol mode with the parameter -1. ssh v1 has known weaknesses and is insecure. Hence a lot of sites disable the ssh v1 protocol.
You can verify this from the shell with ssh -1 me#xxxx.amazonaws.com.
Try other tramp connection methods like ssh, sftp or scpx. You can see all pre-configured connection methods with C-h v tramp-methods.
If Moritz Bunkus's answer doesn't solve the issue, then you can configure the verbosity of tramp's output with
M-x customize-variable RET tramp-verbose RET
In particular, level 6 is "sent and received strings" which might help you to determine whether the "Waiting for prompts from remote shell" is because it isn't receiving a prompt pattern that it recognises, or because of some more critical failure.
If it's simply receiving a prompt it doesn't recognise, then you might look at customizing the tramp-login-prompt-regexp or tramp-shell-prompt-pattern variables.
(Of course if your ssh agent is working correctly, then login prompts shouldn't be relevant.)
If you're running Emacs in Windows, then also see these Q&As:
Emacs: Tramp doesn't work
Using tramp with EmacsW32 and cygwin, possible?

ssh through emacs shell?

I wonder if anyone out there uses ssh through the emacs shell. I am able to connect with the remote machine but I cannot open files to view/edit with emacs using 'emacs filename' as the 'Terminal type "dumb" is not powerful enough to run emacs' (normally emacs would open within the console when connecting through the terminal).
Is this a bad idea to try to use emacs in such a way, or is this possible with a few fixes? Thanks much!
It may not be obvious on first sight, but eshell, the shell that is
implemented in Emacs Lisp works fine with tramp:
Welcome to the Emacs shell
~ $ uname -a
Linux local-machine 2.6.30-1-686 #1 SMP Thu Jul 30 14:45:30 UTC 2009 i686 GNU/Linux
~ $ cd /ssh:user#remote-machine:~
/ssh:user#remote-machine:/home/user $ uname -a
Linux remote-machine 2.6.18-6-686 #1 SMP Thu Aug 20 21:56:59 UTC 2009 i686 GNU/Linux
/ssh:user#remote-machine:/home/user $
A couple of ideas
Source the .bashrc explicitly via . ~/.bashrc and/or rearrange your bash init files and ~/.profile so that this gets loaded inside the emacs shell; then running ssh inside the Emacs shell works just fine
Use the emacs-specific Tramp mode to access remote files via ssh inside your local Emacs -- this is useful if you just need to update/touch/edit a remote file so you would not need to open a remote emacs inside the ssh session started from inside your local emacs.
Emacs has term-mode which is full blown terminal emulator you can run emacs in emacs. Anything you run on terminal will run in term-mode
Also emacs has tramp mode which can open files through ssh.
/scp:user#ipOrHost#port:/
it will transfer files back and forth. you just edit them as you would edit local files.
No need for x11 forwarding or other shenanigans.
You could use ssh x forwarding to run a remote emacs and display it on the local computer. I use Xming X Server when I'm on Windows
You could mount the remote filesystem with ssh and open the locally as normally.
For this I use ExpanDrive (commercial app) when on Windows
You could use emacs Ange ftp over ssh it can open remote files over ftp and ssh.
I use this with cygwin when on Windows
I have been struggling with Xming, which works, but as my internet connection is not the fastest I have to wait more 30 seconds before emacs or any X app even shows up. Also scrolling through a buffer after it has been opened will freeze from time to time => Very annoying
Try No machine (nxserver-freenx server/client). There are free edition servers, absolute the best and fastest solution when you want to connect to a Linux box and use xterm and emacs over X. It shows up immediately and responds so fast. Even over a really slow connection :-) Clients are available for Windows, Mac OS, Linux
Emacs option for ssh : c-x c-f /ssh:user#host:/home/path/
For Reference: Open file via SSH and Sudo with Emacs