收录: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
- We commonly use the
ssh
command to connect to server.1
2
3ssh username@hostname
#example
ssh root@192.168.0.2
- The first name you login, you will be noticed:
1 | The authenticity of host '10.0.0.1 (10.0.0.1)' can't be established. |
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
8Host 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
2ssh 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
andid_rsa.pub
two directories under~/.ssh/
.And then copy the
.key
file path to theIdentityFile
configure I mentioned above.### By password
transfer file from your local to linux server by scp
We can transfer file from source to destination as below
The file above means transfer ./a.txt file to folder /usr/local of the server 10.0.0.2 .1
2
3scp source destination
#example
scp ./a.txt root@10.0.0.2:/usr/localtransfer multiple files
1 | scp source1 source2 destination |
- transfer folder
1 | scp -r source_folder destination |