一、修改服务器配置

1、先登录服务器然后修改服务器配置
[root@iZuf6d9y2x6c8r92unymr1Z pubkey]# vim /etc/ssh/sshd_config

#找到以下内容,去掉前面的注释(#)
PubkeyAuthentication yes
AuthorizedKeysFile      .ssh/authorized_keys

#重启sshd服务
[root@iZuf6d9y2x6c8r92unymr1Z pubkey]# service sshd restart

二、修改MAC本地配置


2、修改本地配置

qierkang@erkangMacPro # ssh-keygen -t rsa
#一路回车即可。默认在~/.ssh 目录生成两个文件:
#id_rsa :私钥 id_rsa.pub :公钥

#将本地公钥复制到服务器
qierkang@erkangMacPro # scp ~/.ssh/id_rsa.pub root@你的公网IP:/home/pubkey/id_rsa.pub

#在服务器端将公钥文件导入认证文件中

[root@iZuf6d9y2x6c8r92unymr1Z pubkey]# cat /home/pubkey/id_rsa.pub >> ~/.ssh/authorized_keys

[root@iZuf6d9y2x6c8r92unymr1Z pubkey]# chmod 700 ~/.ssh 

[root@iZuf6d9y2x6c8r92unymr1Z pubkey]# chmod 600 ~/.ssh/authorized_keys

#最后一步 修改 mac 下的配置文件~/.ssh/config (没有则创建)

qierkang@erkangMacPro # vim ~/.ssh/config


#添加这些内容
Host myprod ### 别名 
Hostname 192.168.xx.xx ###公网 
IP Port 22 ###端口 
User root ###登录账号 
IdentityFile ~/.ssh/id_rsa ###本机私钥地址

 

最终效果如下:

 

GitHub 加速计划 / term / terminal
94.53 K
8.17 K
下载
The new Windows Terminal and the original Windows console host, all in the same place!
最近提交(Master分支:1 个月前 )
3a068269 This adds a basic policy check for DisabledProfileSources, so that organizations can easily disable certain profiles like the Azure one. Closes #17964 ## Validation Steps Performed * Add a policy to disable Azure under HKCU. Disabled ✅ * Add a policy to disable nothing under HKLM. Enabled ✅ (...because it overrides the HKCU setting.) 4 天前
990ed187 We started requiring PowerShell 7+ in #18021 We did not update the code formatting task. 5 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐