1

I wanted to be able to ssh into my google cloud instances with spacemacs. I found: https://github.com/dustinfreeman/dustinfreeman.emacs.d/blob/master/init.el#L50

which is based off of: https://qiita.com/tanatana/items/218b19808f2428b125fe

I added

(require 'tramp)
(add-to-list 'tramp-methods
             '("gcssh"
               (tramp-login-program        "gcloud compute ssh")
               (tramp-login-args           (("%h")))
               (tramp-async-args           (("-q")))
               (tramp-remote-shell         "/bin/sh")
               (tramp-remote-shell-args    ("-c"))
               (tramp-gw-args              (("-o" "GlobalKnownHostsFile=/dev/null")
                                            ("-o" "UserKnownHostsFile=/dev/null")
                                            ("-o" "StrictHostKeyChecking=no")))
               (tramp-default-port         22)))

in my .spacemacs file under the dotspacemacs/user-init function. However, if I spc f f and then type /gcssh: I get the following error in the *debug tramp* buffer.

  backtrace()
  tramp-error(nil user-error "Not a Tramp file name: \"%s\"" "/gcssh:")
  apply(tramp-error nil user-error "Not a Tramp file name: \"%s\"" "/gcssh:")
  tramp-dissect-file-name("/gcssh:")
  helm-ff--create-tramp-name("/gcssh:")
  helm-ff-update-when-only-one-matched()
  run-hooks(helm-after-update-hook)
  helm-log-run-hook(helm-after-update-hook)
  #[0 "\301\206\006\0\303 \304\001\236\204\031\0\211\203\025\0\305\001\306\"\210\307\310!\210\210\300\203N\0\311\312\300\"\210\313 \203I\0\314\313 !r\315\316\317\320\321\005!\322\"\323$\216\324\001@\325\"\210\326\300\301\"\210*\210\202N\0\326\300\301\"\210\327\211\022\207" [nil nil helm--force-updating-p helm-get-current-source candidates-process helm-display-mode-line force helm-log-run-hook helm-after-update-hook helm-log "Update preselect candidate %s" helm-window internal--before-with-selected-window make-byte-code 0 "\301\300!\207" vconcat vector [internal--after-with-selected-window] 2 select-window norecord helm-preselect nil] 7]()
  helm-update()
  helm-check-new-input("/gcssh:")
  helm-check-minibuffer-input()
  #[0 "\010\206\005\0\011?\205 \0\302 r\303\304\305\306\307\005!\310\"\311$\216\312 \210\313 *\262\001\207" [helm-in-persistent-action helm-suspend-update-flag internal--before-save-selected-window make-byte-code 0 "\301\300!\207" vconcat vector [internal--after-save-selected-window] 2 helm-check-minibuffer-input helm-print-error-messages] 7]()
  apply(#[0 "\010\206\005\0\011?\205 \0\302 r\303\304\305\306\307\005!\310\"\311$\216\312 \210\313 *\262\001\207" [helm-in-persistent-action helm-suspend-update-flag internal--before-save-selected-window make-byte-code 0 "\301\300!\207" vconcat vector [internal--after-save-selected-window] 2 helm-check-minibuffer-input helm-print-error-messages] 7] nil)
  timer-event-handler([t 0 0 10000 repeat #[0 "\010\206\005\0\011?\205 \0\302 r\303\304\305\306\307\005!\310\"\311$\216\312 \210\313 *\262\001\207" [helm-in-persistent-action helm-suspend-update-flag internal--before-save-selected-window make-byte-code 0 "\301\300!\207" vconcat vector [internal--after-save-selected-window] 2 helm-check-minibuffer-input helm-print-error-messages] 7] nil idle 0])

Additionally, I tried to use org-babel to connect but nothing happens.

Any ideas, would be greatly appreciated. All the online postings made me believe that it was straight forward. So maybe there is something I'm missing as I am new to emacs,spacemacs, and tramp.

6
  • First question for you, maybe an obvious one, but did you re-evaluate your .spacemacs file after you added the configuration for tramp? Either with SPC f e R or restarting Emacs?
    – shoshin
    Commented Feb 1, 2019 at 6:05
  • Second, assuming you did do that, maybe this issue github.com/emacs-helm/helm/issues/2090 will help? Sounds like you either change the Tramp syntax to simplified with M-x tramp-change-syntax or type your path like /ssh:gcssh:. You'll have to ask another question about org-babel, it isn't clear what you're trying to do.
    – shoshin
    Commented Feb 1, 2019 at 6:11
  • Ah, thanks @shoshin for taking the time to look at this. Yeah, I did run through the basic tests. From the link, you sent me, I'm not sure if it's due to my emacs version (I'm on 26.1). I tried downgrading my version to 25.3 with no avail so it can't be said for certain. Regardless, I attempted the /ssh:gcssh:<user>@<instance>: and it failed with ssh: Could not resolve hostname gcssh: nodename nor servname provided or not known^M. Additionally, M-x tramp-change-syntax only yielded one option default. Lastly, for the org-babel I just assumed, maybe naively one would resolve the other. Commented Feb 1, 2019 at 19:22
  • /ssh:gcssh:<user>@<instance>: is not a valid Tramp name. You have defined gcssh as method, so you must use it like /gcssh:<user>@<instance>: I suppose. Commented Feb 2, 2019 at 20:38
  • SPC f f and then /gcssh: results in the *debug tramp* error I originally posted. Commented Feb 3, 2019 at 14:54

1 Answer 1

5

If you just run gcloud compute config-ssh in the terminal regular ssh tramp will find the instances that are accessible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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