Create Shortcut for SSH Hosts

You frequently visit host 10.0.7.141 for example. It's a waste to type "ssh gcp@10.0.7.141" every time you connect it. So you can create a file ~/.ssh/config, and add follow lines to it:

Host 141

Hostname 10.0.7.141

User gcp

[Port 22]

[IdentityFile ~/.ssh/id_rsa.pub]

Now you can use "ssh 141" to connect to this host.

Or use "scp user@141:/home/user/" to copy files.

With key authorization (see note "Login SSH Server without Password"), you can connect to this host without inputing password. You can copy local file to remote host with "scp myfile 141:/target/path", and copy file on remote host to local folder with "scp 141:/source/path/to/file /target/folder".

Note: IdentifyFile is the shortcut of "-i /path/to/public-key" option of "ssh" command;

原文地址:https://www.cnblogs.com/darkmatter/p/3606810.html