SSH login password-free and secret Git-free operation

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

  1. 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/generation id_rsaand id_rsa.pubi.e. rsa private and public keys, can also ssh-keygen -t rsagenerate the current directory, and then drag ~/.ssh/in. If .sshan existing folder id_rsaand id_rsa.pubfile in this step may be omitted.
  2. The id_isa.pubcopy the contents inside to the server .ssh/authorized_keysin.

    ssh root@xxxx

    cd .ssh

    Edit authorized_keys(if there is no .sshfolder or authorized_keysfile needs to be created), to id_isa.pubcopy the contents to the file.

    vim authorized_keys
  3. 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 rsagenerated public content on the figure

so long as it is used after the machine from the current gitHubin 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

文章若有不对地方,欢迎批评指正

Guess you like

Origin www.cnblogs.com/guoshaobin/p/11237169.html