Mac生成ssh和查看ssh key sshgit
程序员文章站
2024-02-06 19:13:22
...
mac 系统开始就已经为我们安装了ssh 如果没有安装,
首先安装打开终端:$ ssh -v
查看ssh版本
usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
[-D [bind_address:]port] [-e escape_char] [-F configfile]
[-I pkcs11] [-i identity_file]
[-L [bind_address:]port:host:hostport]
[-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
[-R [bind_address:]port:host:hostport] [-S ctl_path]
[-W host:port] [-w local_tun[:remote_tun]]
[user@]hostname [command]
这个表明ssh已经安装.
如果没有安装,在终端输入以下命令
$ ssh-keygen -t rsa -C "youremail@example.com"
一路回车确定下就安装好了。
生成在当前用户名下会有一个.sh文件。
查看 .ssh
$ ls -a ~/.ssh 通过搜索目录
id_rsa
id_rsa.pub
打开 id_rsa.pub文件 里面就有需要的ssh key。
在终端输入命令打开id_rsa.pub
vim ~/.ssh/id_rsa.pub
将.pub中的多有内容拷贝出来填到git账户里面就ok了
Back in your terminal window, copy the contents of your public key file.
For example, in Linux you can cat
the contents.
$ cat ~/.ssh/id_rsa.pub
In Mac OSX, the following command copies the output to the clipboard:
$ pbcopy < ~/.ssh/id_rsa.pub