收录:linux deploy Author:ccyyxx

Abstract

This article will introduce some basic knowledge in linux deployment.

How to connect to the linux server and tranfer files to linux server

  1. We commonly use the ssh command to connect to server.
    1
    2
    3
    ssh username@hostname
    #example
    ssh root@192.168.0.2
  • The first name you login, you will be noticed:
1
2
3
The authenticity of host '10.0.0.1 (10.0.0.1)' can't be established.
ECDSA key fingerprint is SHA256:iy237yysfCe013/l+kpDGfEG9xxHxm0dnxnAbJTPpG8.
Are you sure you want to continue connecting (yes/no/[fingerprint])?

input yes is ok.

  • You can save the server info in the configure file Modify the ~/.ssh/config or /etc/ssh/ssh_config file in order to store information of servers.
    1
    2
    3
    4
    5
    6
    7
    8
    Host host1
    HostName IP Address or DomainName
    User foo

    Host host2
    HostName IP Address or DomainName
    User foo
    IdentityFile ~/.ssh/foo.key

After being configured, just login by

1
2
ssh host1
ssh host2

  • Two ways login in ssh ### By key

    The way to create ssh key

    1
    ssh-keygen

    After being executed, you will find id_rsa and id_rsa.pub two directories under ~/.ssh/.

    And then copy the .key file path to the IdentityFile configure I mentioned above.

    ### By password

transfer file from your local to linux server by scp

  1. We can transfer file from source to destination as below

    1
    2
    3
    scp source destination
    #example
    scp ./a.txt root@10.0.0.2:/usr/local
    The file above means transfer ./a.txt file to folder /usr/local of the server 10.0.0.2 .

  2. transfer multiple files

1
2
3
scp source1 source2 destination
#example
scp ./a.txt ./b.txt root@10.0.0.2:/usr/local
  1. transfer folder
1
2
3
scp -r source_folder destination
#example
scap -r ./folder1 root@10.0.0.2:/usr/local