iTerm has recently introduced a feature called Shell Integration. Using this feature, we can upload and download files conveniently directly from iTerm 2. Drag a file into the window when pressing Option Key uploads the file to the remote ssh connection. Right-click on a file using ls command will bring up a context list containing downloading the file.

Some tips

To successfully utilize this feature, you need to ensure some tweaks have been made on the server.

  1. Click “iTerm2->Install Shell Integration” when sshing into the remote server.
    This will run
curl -L | bash

on the remote server, which equals to

curl -L`basename $SHELL` >> \
~/.iterm2_shell_integration.`basename $SHELL`

and adding this into the login script.

source ~/.iterm2_shell_integration.`basename $SHELL`
  1. Ensure the server has a correct FQDN as hostname and can be connected through this hostname.
    You can use
hostname -f

to check it.
3. If you’re using private key authentication, then you should have id_rsa in your .ssh directory. However, you should also put in your .ssh directory to use this feature.

You may need this command.

ssh-keygen -y -f id_rsa >
Using Shell Integration in iTerm 2 to Upload/Download Files from Remote SSH Connections

Leave a Reply

Your email address will not be published. Required fields are marked *