SSH login password-free and secret Git-free operation
After each package needs to kick on the packet to be passed corresponding server allowing testers to download and install, but every time need to re-enter the password when ssh or scp; use of git hosting platform just change the password you need to enter a password. This article is mainly about free password to log on to a remote server implementation steps Git-free and secret operations, there is a commonly used commands scp
.
SSH password-free
The client generates a pair of keys (public / private)
Enter the following command in the terminal:
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
Parameters:- -t type of encryption algorithm, using rsa algorithm is here
- -P Specify the private key password, you can not do not need to specify
- -f specified location path generated secret key
- The direct command
~/.ssh/
generationid_rsa
andid_rsa.pub
i.e. rsa private and public keys, can alsossh-keygen -t rsa
generate the current directory, and then drag~/.ssh/
in. If.ssh
an existing folderid_rsa
andid_rsa.pub
file in this step may be omitted.
The
id_isa.pub
copy the contents inside to the server.ssh/authorized_keys
in.ssh root@xxxx
cd .ssh
Edit
authorized_keys
(if there is no.ssh
folder orauthorized_keys
file needs to be created), toid_isa.pub
copy the contents to the file.vim authorized_keys
Finally, then ssh will lose their passwords, then you no longer need to enter a password.
Git dense Free Operation
Free Git the secret operation is essentially free SSH secret operation. Because most of git hosting platform supports SSH, if we configure SSH keys we do not have to enter a password. GitHub to take an example:
In the setting:
the ssh-keygen -t rsa
generated public content on the figure
so long as it is used after the machine from the current gitHub
in clone
-time code, even if the change password can no longer enter the password.
SCP command
远程服务器文件和本地文件的交互大部分使用scp
命令。
把本地文件拷贝到远程
scp 本地文件 user@host:路径/
例:将桌面的文件
test.txt
拷贝到远程服务器根目录下scp test.txt [email protected]:/
将该文件拷贝到远程服务器根目录并改名为
test1.txt
:scp test.txt [email protected]:/test1.txt
文件地址可以是相对地址也可以是绝对地址。
把本地目录拷贝到远程
scp -r 本地目录 user@host:路径/
例:将桌面的
group
文件夹拷贝到远程服务器的根目录下:scp -r group [email protected]:/home/
-r 表示递归文件夹中所有文件。
拷贝远程文件到本地
scp user@host:文件名 本地路径
例:拷贝远程服务器文件
test1.txt
拷贝到桌面并改名为test.txt
scp [email protected]:/test1.txt ./test.txt
拷贝远程目录到本地
scp -r user@host:文件名 本地路径
例:拷贝远程服务器目录到本地
scp -r [email protected]:/home/group ./group
文章若有不对地方,欢迎批评指正