Skip to content

Commit

Permalink
Merge pull request #97 from gigalixir/tim/envvar-for-ssh-identity
Browse files Browse the repository at this point in the history
support GIGALIXIR_IDENTITY_FILE for ssh
  • Loading branch information
gigatim committed Jan 31, 2022
2 parents 787d5ac + bce21b7 commit 283d3bb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
# built documents.
#
# The short X.Y version.
version = u'1.2.4'
version = u'1.2.5'
# The full version, including alpha/beta/rc tags.
release = u'1.2.4'
release = u'1.2.5'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
7 changes: 7 additions & 0 deletions docs/source/runtime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ The :bash:`-o` option lets you pass in arbitrary options to :bash:`ssh`. Somethi
If you have multiple SSH keys on your machine, you may need to explicitly specify which one the Gigalixir CLI should use when connecting. If you get a :bash:`Permission denied (publickey)` error when attempting to run commands through the CLI but your :bash:`git push gigalixir master` (or equivalent) succeeds, first try specifying the SSH key you want to use with the option above.

To avoid having to specify the key file on each run, set the :bash:`GIGALIXIR_IDENTITY_FILE` to the path to your private key.

.. code-block:: bash
export GIGALIXIR_IDENTITY_FILE=$HOME/.ssh/gigalixir
You can use :bash:`-o` to specify any option or options to :bash:`ssh`.

.. _`Launching a remote console`:
Expand Down
8 changes: 7 additions & 1 deletion gigalixir/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import re
import pipes
import logging
import urllib
Expand Down Expand Up @@ -92,7 +93,7 @@ def scale(host, app_name, replicas, size):
if replicas != None:
body["replicas"] = replicas
if size != None:
body["size"] = size
body["size"] = size
r = requests.put('%s/api/apps/%s/scale' % (host, quote(app_name.encode('utf-8'))), headers = {
'Content-Type': 'application/json',
}, json = body)
Expand Down Expand Up @@ -140,6 +141,11 @@ def ssh_helper(host, app_name, ssh_opts, ssh_cmd, capture_output, *args):
if len(keys) == 0:
raise Exception("You don't have any ssh keys yet. See `gigalixir account:ssh_keys:add --help`")

# use the identity file specified by environment variable
id_file = os.environ.get("GIGALIXIR_IDENTITY_FILE")
if id_file and not re.match(r'(^|[\s])-i', ssh_opts):
ssh_opts = (ssh_opts + " -i " + id_file).strip()

r = requests.get('%s/api/apps/%s/ssh_ip' % (host, quote(app_name.encode('utf-8'))), headers = {
'Content-Type': 'application/json',
})
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
url='https://github.com/gigalixir/gigalixir-cli',
author='Jesse Shieh',
author_email='jesse@gigalixir.com',
version='1.2.4',
version='1.2.5',
packages=find_packages(),
include_package_data=True,
install_requires=[
Expand Down

0 comments on commit 283d3bb

Please sign in to comment.