- 一、安装 Git
- 二、在 window 中,右键打开` Git Bash Here`
- 三、SSH 远程登入服务器命令
- 四、SSH 免密远程登入服务器
- 4.1 创建 SSH key
- 4.2 把 SSH 公钥复制到服务器
- 五、设置快捷命令登入
- 5.1 创建一个 pi.txt 文件(可自行定义)
- 5.2 把 pi.exe 文件拷贝到 Git 安装目录 usrbin 下
- 六、完结
二、在 window 中,右键打开Git Bash Here
三、SSH 远程登入服务器命令
#以树莓派服务器为例 $ ssh pi@192.168.1.10
四、SSH 免密远程登入服务器
注意:退出服务器在执行下面步骤
4.1 创建 SSH key
在 Git Bash 中:
#创建 ssh key $ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa): /c/Users/Administrator/.ssh/id_rsa already exists. Overwrite (y/n)? y Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub The key fingerprint is: SHA256:BMdbAzgiX0I4qdKJMIFScbt1aPx4lPBd2TXQcFtFE5c honning@z The key's randomart image is: +---[RSA 3072]----+ |ooo=o ooo. .=+BX| |= =.oo+*.oo.. oE*| |o= =.+=.*o.. . | |+ o .+ *. | |. . . S | | . | | | | | | | +----[SHA256]-----+
4.2 把 SSH 公钥复制到服务器
# 中间需要输入服务器的密码 $ ssh-copy-id pi@192.168.1.10 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/c/Users/Administrator/.ssh/id_rsa.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys pi@192.168.1.10's password: Number of key(s) added: 1 Now try logging into the machine, with: "ssh 'pi@192.168.1.10'" and check to make sure that only the key(s) you wanted were added.
现在可以直接使用 ssh 命令登入,不需要输入密码
5.1 创建一个 pi.txt 文件(可自行定义)
文件内容如下:
#!F:Gitusrbinbash ssh pi@192.168.1.10
5.2 把 pi.exe 文件拷贝到 Git 安装目录 usrbin 下
- 修改 pi.txt 文件的后缀名为 .exe
- 拷贝到 Git 的安装目录的 usr/bin 下(我的安装目录是:F:Gitusrbinbash)
注意:文件名( pi.exe )不要和 usrbin 下的命令名冲突!
如果不出意外,现在应该可以使用快捷命令了。
在 Git Bash 中直接输入 pi 就可以远程免密登入服务器了。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)