mac免密码登录linux

一、在Mac下完成的操作

yzydeMacBook-Pro:~ yzy$ cd .ssh 

yzydeMacBook-Pro:.ssh yzy$ ssh-keygen -t rsa #生成公钥和私钥,输入次命令后一直空格就好

Generating public/private rsa key pair.
Enter file in which to save the key (/Users/yzy/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:                                 #此处为一直需要空格内容
yzydeMacBook-Pro:.ssh yzy$ scp id_rsa.pub root@***.**.***.***:~/.ssh  #将公钥拷贝到Linux的.ssh目录下

二、在Linux下完成的操作

[root@hackintosh ~]# cd .ssh 
[root@hackintosh .ssh]# cat id_rsa.pub >> authorized_keys 

此时已完成免密登录Linux

三、小技巧,让Mac使用别名登录Linux

yzydeMacBook-Pro:.ssh yzy$ vim config
Host            alias #自定义别名
HostName        hostname  #替换为你的ssh服务器ip或domain
Port            port #ssh服务器端口,默认为22
User            user #ssh服务器用户名
IdentityFile    ~/.ssh/id_rsa #第一个步骤生成的公钥文件对应的私钥文件





猜你喜欢

转载自blog.csdn.net/yangzhyu/article/details/80530034