17 private links
SSH, or secure shell, is the most common way of connecting to Linux hosts for remote administration. Although the basics of connecting to a single host are often rather straight forward, this can become unwieldy and a much more complicated task when you begin working with a large number of remote systems.
Fortunately, OpenSSH allows you to provide customized client-side connection options. These can be saved to a configuration file that can be used to define per-host values. This can help keep the different connection options you use for each host separated and organized, and can keep you from having to provide extensive options on the command line whenever you need to connect.
In this guide, we'll cover the basics of the SSH client configuration file, and go over some common options.
-
Generate SSH key:
$ ssh-keygen -t rsa -C <email1@example.com>
-
Generate
another SSH key
:$ ssh-keygen -t rsa -f ~/.ssh/accountB -C <email2@example.com>
Now, two public keys (id_rsa.pub, accountB.pub) should be exists in the
~/.ssh/
directory.$ ls -l ~/.ssh # see the files of '~/.ssh/' directory
-
Create config file
~/.ssh/config
with the following contents:$ nano ~/.ssh/config Host bitbucket.org User git Hostname bitbucket.org PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa Host bitbucket-accountB User git Hostname bitbucket.org PreferredAuthentications publickey IdentitiesOnly yes IdentityFile ~/.ssh/accountB
-
Clone from
default
account.$ git clone git@bitbucket.org:username/project.git
-
Clone from
accountB
account.$ git clone git@bitbucket-accountB:username/project.git
scp allows files to be copied to, from, or between different hosts. It uses ssh for data transfer and provides the same authentication and same level of security as ssh.