ssh and scp

ssh command linux remote login, its default port: 22, at work this out often modify the default port values.

Scp commands for remote file copy of each other.


 

scp remote file copy :

[Root @ jerry a] #ls # following files in a directory

2.txt 3.txt 4.txt 5.txt 1.txt
[Jerry the root @ A] #scp 192.168.27.128:/root/a/test.txt. # Copy another document into the current host test.txt Contents

of The Authenticity of Host '192.168.27.128 (192.168.27.128)' Not CAN BE ESTABLISHED.
the ECDSA Key Fingerprint IS. 17:. 5A: 69: DB: E5: ab &: 6C: 35: FB: A6: F2: 4C: C8 : bc: D3:. c2
Are you the Sure you want to Connecting the Continue (yes / NO)? yes
Warning:. Permanently added '192.168.27.128' (ECDSA) to List of Known hosts at The
[email protected]'s password: # require a password to another host
100% 0 0.0KB / S 00:00 test.txt   
[Jerry the root @ a] #ls
1.txt 2.txt 3.txt 4.txt 5.txt test.txt

If you want to copy the file is a directory, you need to add the -r option, but can also go on another host or upload files from the current directory Host:

[Jerry the root @ A] #mkdir Test
[Jerry the root @ A] #ls
1.txt 2.txt 3.txt 4.txt 5.txt Test test.txt
[Jerry the root @ A] -R & lt #scp Test 192.168.27.128 : / root / b    # copies the current test directory to another host / root / b in
[email protected]'s password: # password another host
[root @ jerry a] #

 

Check in on another host:

root@jerry b]#ls
test


 

ssh remote login-free secret:

[root@jerry b]#ssh-keygen    #生成密钥
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
35:ab:4f:5f:60:f6:e5:a3:14:56:82:1e:5c:29:87:96 root@jerry
The key's randomart image is:
+--[ RSA 2048]----+
|            o..  |
|          .Eoo   |
|          ++o. . |
|         ..o. o  |
|        S ..+o  .|
|         . o.o.o |
|        . .  .o..|
|         o .... .|
|          . ..   |
+-----------------+
[root@jerry b]#ssh-copy-id 192.168.27.129    #发送公钥到另一端
The authenticity of host '192.168.27.129 (192.168.27.129)' can't be established.
ECDSA key fingerprint is c0:d8:9b:d9:05:37:51:4e:42:16:1c:a2:17:6c:5a:b7.
Are you sure you want to continue connecting (yes/no)? yes
/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
[email protected]'s password:     #另一台主机的密码
Number of key(s) added: 1
Now try logging into the machine, with:   "ssh '192.168.27.129'"
and check to make sure that only the key(s) you wanted were added.
 
View Verification:
[root @ jerry b] #ssh 192.168.27.129 # without a password to log after completion of adhesion Free
Last Login: Tue Jul-2019 19:48:11 from 2 192.168.27.1
[Jerry the root @ ~] A #ip
. 1: LO: <the LOOPBACK, the UP, LOWER_UP> UNKNOWN MTU 65536 qdisc allows users to noqueue State of qlen. 1
    Link / Loopback 00: 00: 00: 00: 00: 00 brd 00: 00: 00: 00: 00: 00
    inet 127.0.0.1/8 scope Host LO
       Forever Forever preferred_lft valid_lft
    inet6 :: a 1/128 scope Host
       valid_lft preferred_lft Forever Forever
2: ens33: <BROADCAST, the MULTICAST, the UP, LOWER_UP> 1500 qdisc allows users to pfifo_fast MTU 1000 State of qlen the UP
    Link / ether 00: 0c: 29: C2: 9E: brd FF 7E: FF: FF: FF: FF: FF
    inet 192.168.27.129/ 24-brd 192.168.27.255 scope, Ltd. Free Join ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fec2:9e7e/64 scope link
       valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000
    link/ether 52:54:00:d9:3d:91 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
    link/ether 52:54:00:d9:3d:91 brd ff:ff:ff:ff:ff:ff
 
/Root/.ssh following file is encrypted login Free one of:
[root@jerry ~]#ls .ssh
authorized_keys  known_hosts
Information is free and confidential login host public key storage
 

After login you can achieve free secret secret remote free copy:
[root@jerry b]#scp 192.168.27.129:/root/a/*.txt .
1.txt                                                                                                100%    0     0.0KB/s   00:00   
2.txt                                                                                                100%    0     0.0KB/s   00:00   
3.txt                                                                                                100%    0     0.0KB/s   00:00   
4.txt                                                                                                100%    0     0.0KB/s   00:00   
5.txt                                                                                                100%    0     0.0KB/s   00:00   
test.txt                                                                                             100%    0     0.0KB/s   00:00  
No password is required to copy the success.

 

Guess you like

Origin www.cnblogs.com/getbird/p/11122896.html
scp