preface

Well begun is half done. In development, good tools are half done.

In practice, before “Alfred + SSH +iterm” was used, each connection between machines in various environments was called

1. Open a terminal 2. SSH root @ IP 3. Enter the password 4 ps - ef | grep server / / findlog dir
5. cd logDir // Target directory 6. Bala Bala View logsCopy the code

That is, there are at least five steps to go through before you actually start looking for problems in the logs. Inadvertently, 10 minutes passed, the problem has not started to find it

With the help of Alfred + SSH + Iterm, pleasure is created. Just do one “random” move (see picture below) and go straight to step 6.

Let’s talk about how to achieve this great efficiency and double cool operation.

Avoid close login

Here’s a quick tip. Password-free access to the machine. Premise: By default your MAC already has iTerm2 installed. Scenario: Normally, we want to connect to a remote server.

1. Open iTerm2 2. SSH [email protected] 3. Enter the passwordCopy the code

In practice, there are multiple remote servers that need to be connected. Each operation as above, it is tedious. Especially when it comes to complex passwords

Use SSH config

To implement password login, use the SSH Config function of OpenSSH. SSH /config. If it does not exist, create one and vim ~/.ssh/config

Host aliyun
  HostName 50.100.11.10
  User root
  Port 22
Copy the code

Save and exit. You can then type SSH aliyun in iTerm2, press Enter, and enter the password. Note that you no longer need to type SSH [email protected], just enter your password to log in

Set the encrypted login

The method is to use the ssh-copy-id function, which copies the local key to the remote machine to be connected, thereby authorizing the connection. Iterm terminal input:

  • (Optional) If your machine has not generated an SSH key, enter it. If it already exists, ignore this step

$ ssh-keygen

  • Copy the key to the remote destination server

$SSH – copy – id – [email protected] I

Ssh-copy-id automatically appends the generated public key id_rsa.pub to ~/.ssh/authorized_keys of the remote host, so that you do not need to enter a password for future SSH connections.

  • Once set, connect to see what happens

$ ssh aliyun

You’ll find that you can wait for the remote server in one step. Still, open the terminal iTerm2. Alfred is needed for a more convenient login to a remote server

Installation of Alfred

Alfred is the no. 1 productivity software for MAC, which shows its popularity. There are feelings once met, missed for life. Alfred is easy to install, but the free version is harder to find, so use your search capabilities.

This is Alfred’s plug-in. A plugin for SSH: Alfred-ssh. It is an overstatement to love this plugin. Here are the specific usage scenarios and configurations

So far, you’ll notice that without using Alfred, you’ve implemented iTerm2 in one step. Yes, but with Alfred, we can connect to remote servers in an easier way

The installationalfred-sshThe plug-in

The connection is as follows: github.com/deanishe/al… Download the latest version: Secure-shell-0.8.0. alfredWorkflow. Double-click to automatically add it to Alfred’s Workflow page

At this point, alfred-SSH is introduced into Alfred, and you can use Alfred to open the remote server. Type in SSH aliyun, and you’ll see that aliyun is connected to the terminal. But you’ll notice that this terminal displays a MAC native terminal, and we’ve long liked iTerm2, which is much better than the MAC native terminal.

Install the Alfred integrated Iterm2 configuration

So if you want to use Iterm2 as a terminal, you need to configure it. As shown below, open the Settings for iTerm2

  1. install iTerm2 plugin for Alfred
  2. Configure Url Schemes for iterm

Alfred Preferences → Features → Terminal/Shell change the Application value to Custom, as shown in the figure below

It also displays a large input box, which requires a piece of code to be entered, and the source of the code is shown below

Install the Alfred plugin custom-iterm-applescripts-for- Alfred

Click on the iTerm2 Plugin for Alfred, which is a nice custom Applescript, and select the applescript command based on your version of Iterm, as shown below

My iTerm2 version is Build 3.2.9, so I select the command For 3.1.1, select copy curl… , paste it into iTerm2 and press Enter, as shown below

Paste it into the big input box above, Alfred’s configuration: Alfred Preferences → Features → Terminal/Shell → Application → Custom

ItermURL Schemes configuration

Preferences → Profiles → PROFILE_NAME → General → URL Schemes select SSH and set it to SSH activation by default

At this point, the configuration is complete

Great discomfort

Effect of acceptance

enter

As you can see, the net effect is to connect directly to Aliyun’s remote server by typing a command into Alfred: SSH Aliyun. At this point, our goal has been achieved.

The advanced

In the actual work, the online machine is to access through the fortress machine, first to obtain the verification code, as well as password, the steps are more troublesome. At this point, the artifact is still in its power, and it’s done all at once: Now, it’s time to use another artifact: TMUx, tMUx combined with Alfred, invincible mode. Tmux Use See also: Remote Terminal Artifact – TMUX

Copyright [email protected], [email protected], reproduced by indicating the original link

Alfred integrated SSH + Iterm for productivity enhancement