Skip to content

Use SSH to manage remote servers like xshell, mobaxterm other tools.

License

Notifications You must be signed in to change notification settings

b40yd/dotfairy-ssh-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

build License Supports Emacs 27.1-28.x

dotfairy-ssh-manager

Use SSH to manage remote servers like xshell, mobaxterm or other tools.

Feature

  • session manager
  • save session to file
  • 2FA(TOTP)
  • proxy server
  • batch session execute command
  • upload and download

TODOs

  • Optimize upload and download, UI progress display
  • support other solution

Install

You need install quelpa.el, ssh-manager using this package install. first:

;; Use quelpa install packages
(use-package quelpa
  :init
  (setq quelpa-upgrade-p dotfairy-quelpa-upgrade
        quelpa-update-melpa-p nil
        quelpa-checkout-melpa-p nil
        quelpa-dir (expand-file-name "quelpa" user-emacs-directory)))

(use-package quelpa-use-package)
(eval-when-compile
  (require 'quelpa-use-package))

Now use-package will use straight.el.

(use-package ssh-manager
  :ensure nil
  :quelpa (ssh-manager :fetcher github :repo "7ym0n/dotfairy-ssh-manager")
  :bind (("C-c m s s" . ssh-manager-switch-to-server)
        ("C-c m s u" . ssh-manager-upload-or-download-files-to-remote-host)
        ("C-c m s m" . ssh-manager)
        ("C-c M-s" . ssh-manager-show-ssh-session-groups))
  :init
  (setq ssh-manager-sshpass-path (expand-file-name "sshpass" user-emacs-directory)))

If you have many server management, it is recommended to use auth-sources configuration. e.g ~/.emacs.d/.ssh/test.gpg:

host "demo"
kind "proxy"
proxy-host "localhost"
proxy-port "22"
proxy-user "root"
proxy-password ""
realhost "127.0.0.1"
port "22"
user "root"
password ""
totp-kind "FreeOTP"
totp-key ""
totp-message "verification code:"

If you have TOTP, you may also need to set ssh-manager-totp-hooks.

;; eg. default custom totp-hooks
(setq ssh-manager-totp-hooks '((:name "Custom"
    :function (lambda (totp-key)
        (setq totp-key (read-string "Enter TOTP key: "))))))

Do not use proxy and TOTP, E.g:

host "demo"
kind ""
proxy-host ""
proxy-port "22"
proxy-user ""
proxy-password ""
realhost "120.10.10.10"
port "22"
user "root"
password "meiyoumima"

Depends

  • sshpass
  • oathtool
  • rsync or scp
  • ssh

Notes:

choice scp upload or download files, it's don't show progress.

You can install sshpass through ssh-manager-install-tools.

MacOS:

brew install oath-tookit
# or
port install oath-tookit

Archlinux:

sudo pacman -Syy oath-tookit

debian:

sudo apt-get install oath-tookit

Usage

  1. ssh manager
    1. batch an command line to remote server muilt-term
    2. upload and download

Displays the buffer for batch execution of commands, use M-x: ssh-manager-show-ssh-session-groups.

SSH manager mode needs to be started for batch command execution. use M-x: ssh-manager or open a file buffer, set ssh-manager-mode.

If you execute ssh-manager-upload-or-download-files-to-remote-host on the buffer, the current buffer file will be uploaded. You need to upload a directory or multiple files. You need to enter dired and marked files or directory, after press the shortcut key C-c C-<return>.

batch an command line to remote server muilt-term

  • C-c C-a add a term buffer to groups.
  • C-c C-r remove a term buffer to groups.
  • C-c C-. send current command line to all term of groups
  • C-c C-c send current buffer to all term of groups.
  • C-c C-e send region to all term of groups.

upload and download

  • upload a file to test server
  • upload muilt file to server
  • download a file to local /tmp
M-x: ssh-manager-upload-or-download-files-to-remote-host

About

Use SSH to manage remote servers like xshell, mobaxterm other tools.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published