MAC SSH Key Login:
General Mac If you want to login through SSH key, the general practice, self-generated key pair, the advantage is that they only keep the private key, the public key can be placed any server, if you accept someone else to the private key, can only save one, if there are multiple private keys to you, it is not convenient to manage, so it is recommended that you generate Public key Upload Server, the following steps:
1. Through the Mac terminal, Ssh-keygen-t rsa-c "[email protected]" to generate a key pair, the public key is uploaded to the server corresponding to the user. Ssh/authorized_keys
2. Login to the server via SSH [email protected]
3. If you want to achieve fast landing, by means of aliases,
In the Mac. ssh/directory, create a new config file, vi to edit the file, with the following content:
Host mm58 #设置别名, such as Mm58
HostName 192.168.x.x #域名或ip
Port #默认端口, can be modified according to the actual situation
User SSL #登陆用户, such as SSL
Identityfile/users/haiwai02/.ssh/id_rsa #加载私钥存放位置
After saving the exit, you can log in directly by the following aliases,
SSH mm58 #即可实现密钥登陆
In addition, the general situation we need to login to more than one server, you can continue to add in the configuration file, the private key does not need to add, a common one can, as follows, we added a Foo account:
Host MM57
HostName x.x.x.x
Port 22
User Foo
Host mm58 #设置别名, such as Mm58
HostName 192.168.x.x #域名或ip
Port #默认端口, can be modified according to the actual situation
User SSL #登陆用户, such as SSL
Identityfile/users/haiwai02/.ssh/id_rsa #加载私钥存放位置
MAC SSH Key Login