To Perform Batch shutdown, you must configure the SSH dual-host trust.
Host a 192.168.1.241
Host B 192.168.1.212
Obtain a pub key on machine A, that is, a public key.
After executing this command: SSH-keygen-T RSA
In ~ /. Ssh/directory
Use the SCP command to copy the public key to machine B
SuSE-Linux :~ /. Ssh # SCP id_rsa.pub [email protected]:/tmp/
Copied
Enter machine B
Cd ~ /. Ssh/
This directory
Copy the public key of server a to the authorized_keys file.
Linux-218 :~ /. Ssh # Cat/tmp/id_rsa.pub> authorized_keys
Set the permission to 600.
Return to server a for testing
Success
A strange problem occurred when configuring the second server.
Host C 192.168.1.218
The. Ssh Folder does not exist in the root user's home directory.
According to the online statement, it is automatically generated after executing SSH localhost on the C Machine
Then configure as is.
The above is the root user trust relationship configuration. to configure a common user trust relationship, You Can Su to the corresponding user for the above configuration.
SCP is a method for transferring files to each other in Linux.
1. Push: first log on to the local machine and push the local files to the remote host.
Command Format:
1. SCP local_file [email protected] _ IP: remote_folder
2. SCP local_file [email protected] _ IP: remote_folder/remote_file
3. SCP local_file remote_ip: remote_folder
4. SCP local_file remote_ip: remote_folder/remote_file
The user name is specified for the 1st and 2nd commands. You need to enter the password after executing the command. Only the remote directory is specified for the 1st directories, and the file name remains unchanged;
2nd specified file names;
No user name is specified for the 3rd user name. After the command is executed, enter the user name and password. Only the remote directory is specified for the 3rd directories, and the file name remains unchanged;
4th specified file names;
Example: log on to your local machine (172.160.12.pdf) and push the local file 1.mp3 to the remote host 172.160.13.
1. SCP/home/SPACE/music/1.mp3 [email protected]:/home/root/Others/music
2. SCP/home/SPACE/music/1.mp3 [email protected]:/home/root/Others/music/001.mp3
3. SCP/home/SPACE/music/1.mp3 172.160.13:/home/root/Others/music
4. SCP/home/SPACE/music/1.mp3 172.160.13:/home/root/Others/music/001.mp3
The first example is to push 1.mp3 from the local/home/SPACE/musicdirectory to the/home/root/Others/music directory of 17.00.13 without changing the file name.
The 2nd example is to push 1.mp3 from the local/home/SPACE/music directory to the/home/root/Others/music directory of 17.00.13 with the file name 001.mp3.
The first example is to push 1.mp3 from the local/home/SPACE/musicdirectory to the/home/root/Others/music directory of 17.00.13 without changing the file name.
The 4th example is to push 1.mp3 from the local/home/SPACE/music directory to the/home/root/Others/music directory of 17.00.13 with the file name 001.mp3.
Ii. Pull Mode: copy the data from the remote server to the local server. You only need to change the order of the last two parameters in the push mode.
Command Format:
1. SCP [email protected] _ IP: remote_folder/remote_file local_folder/local_file
2. SCP [email protected] _ IP: remote_folder/remote_file.
Example: log on to the Local Machine (172.160.12.pdf, copy the 1.mp3 file on 172.160.13to the local machine)
1. SCP [email protected]:/home/root/Others/music/1.mp3/home/SPACE/music/001.mp3
2. SCP [email protected]:/home/root/Others/music/1.mp3.
The first example is to copy the 1.mp3 file in the/home/root/Others/musicdirectory of 172.160.13 to the/home/SPACE/musicdirectory of the Local Computer, with the file name 001.mp3.
In the 2nd example, copy the 1.mp3 file in the/home/root/Others/musicdirectory of 172.160.13 to the current working directory of the local machine, with the file name unchanged.
Note: if you cannot directly connect to the target host after several hops, you can obtain the target file through level-1 access.
For example, the Local Machine (172.160.12) First connects to 172.160.13, then connects to 172.160.14, then connects to 172.160.15, and wants to obtain files from 15 to the Local Machine 12.
Pull Type: You can use 172.160.14 to pull files on 172.160.15, then pull 14 files on 172.160.13, and finally pull files on 172.160.12 and 13 files.
Push mode: You can push data to 172.160.14 through 172.160.15, then to 172.160.13 on 14, and finally to 172.160.12 on 13.
Linux Command-based SFTP
SFTP commands can be used to upload and download files through SSH. SFTP is a common file transfer tool. It is used in a similar way as FTP, but it uses SSH as the underlying transmission protocol, therefore, the security is much better than FTP.
Common Methods
Format: SFTP
Use SFTP to connect to
Format: sftp-oport = <port>
Use SFTP to connect to
Format: SFTP <user >@< host>
Use SFTP to connect to
Format: sftp-oport = <port> <user >@< host>
Connect to
Common commands for SFTP connection success are as follows:
Help /? Print help information.
PWD: view the current directory of the remote server;
Lpwd to view the current directory of the local system.
CD <dir> change the current directory of the remote server to <dir>;
LCD <dir> change the current directory of the local system to <dir>.
Ls displays the file name of the current directory on the remote server;
Ls-l displays the detailed list of files in the current directory on the remote server;
Ls <pattern> displays the file name of the remote server that meets the specified mode <pattern>;
Ls-L <pattern> displays the detailed list of objects that match the specified mode on the remote server.
Lls displays the file name of the current directory on the local system;
Other lls parameters are similar to those of the LS command.
Get <File> download a specified file <File>;
Get <pattern> downloads the file that meets the specified mode <pattern>.
Put <File> upload a specified file <File>;
Get <pattern> uploads objects that conform to the specified mode <pattern>.
Whether the progress of file transfer is displayed during the Progress switchover.
Mkdir <dir> create a directory on the remote server;
Lmkdir <dir> create a directory on the local system.
Exit/quit/Bye to exit SFTP.
! Start a local shell.
! <CommandLine> run the local command line.
Other Commands include chgrp, chmod, chown, LN, lumask, rename, RM, rmdir, symlink, and version.
SSH trust SFTP usage SCP usage [go]