In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what are the commonly used and important SSH commands". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn "what are the commonly used and important SSH commands"?
OpenSSH is a free version of the SSH connection tool. Telnet,rlogin and ftp users may not realize that the passwords they transmit over the Internet are unencrypted, but SSH is encrypted and OpenSSH encrypts all communications (including passwords), effectively eliminating eavesdropping, connection hijacking and other attacks. In addition, OpenSSH provides secure tunneling and a variety of authentication methods to support all versions of the SSH protocol.
SSH is a great tool, and if you want to connect to a server remotely on the Internet, then SSH is the best candidate. Here are the 25 best SSH commands voted online, which you must keep in mind.
(note: some long commands appear truncated in this article. If you need to read the complete command, you can copy the entire line into your notepad to read. )
1. Copy the SSH key to the target host and enable password-free SSH login.
Ssh-copy-id user@host
If you do not already have a key, use the ssh-keygen command to generate it.
2. Open the tunnel from port 80 of a host to port 2001 of the local host
Ssh-N-L2001:localhost:80 somemachine
Now you can type http://localhost:2001 directly into the browser to visit the site.
3. Output your microphone to the speakers of the remote computer
Dd if=/dev/dsp | ssh-c arcfour-C username@host dd of=/dev/dsp
The sound from your microphone port will be output on the speaker port of the SSH target computer, but unfortunately, the sound quality is poor and you will hear a lot of hissing.
4. Compare remote and local files
Ssh user@host cat / path/to/remotefile | diff / path/to/localfile-
This command is useful when comparing local and remote files for differences.
5. Mount the directory / file system through SSH
Sshfs name@server:/path/to/folder / path/to/mount/point
Download sshfs from http://fuse.sourceforge.net/sshfs.html, which allows you to mount a directory securely across the network.
6. Establish a SSH connection through an intermediate host
Ssh-t reachable_host ssh unreachable_host
Unreachable_host represents a host that cannot be accessed directly from the local network, but can be accessed from the same network as reachable_host. This command creates a connection to unreachable_host through a "hidden" connection to unreachable_host.
7. Copy your SSH public key to the remote host and enable password-less login-a simple method
Ssh-copy-id username@hostname
8. Connect directly to host A, which can only be connected through host B.
Ssh-t hostA ssh hostB
Of course, you need to be able to access host A.
9. Create a persistent connection to the target host
Ssh-MNf @
Create a persistent connection to the target host in the background and use this command in conjunction with your configuration in ~ / .ssh / config:
Host host ControlPath ~ / .ssh / master-%r@%h:%p ControlMaster no
All SSH connections to the target host will use persistent SSH sockets, which is useful if you use SSH to periodically synchronize files (using rsync/sftp/cvs/svn) because no new sockets are created each time a SSH connection is opened.
10. Connect the screen through SSH
Ssh-t remote_host screen-r
Connect directly to the remote screen session (saving the useless parent bash process).
11. Port detection (knock on the door)
Knock 3000 4000 5000 & & ssh-p user@host & & knock 5000 4000 3000
Click on a port to open a service port (such as SSH), and then click to close the port, you need to install knockd first. Here is an example of a configuration file.
[options] logfile = / var/log/knockd.log [openSSH] sequence = 3000 INPUT 5000 seq_timeout = 5 command = / sbin/iptables-An INPUT-I eth0-s% IP%-p tcp-dport 22-j ACCEPT tcpflags = syn [closeSSH] sequence = 5000 seq_timeout = 5 command = / sbin/iptables-D INPUT-I eth0-s% IP%-p tcp-dport 22-j ACCEPT tcpflags = syn
12. Delete a line from the text file, a useful fix
Ssh-keygen-R
In this case, it is best to use professional tools.
13. Run complex remote shell commands through SSH
Ssh host-l user $(remote
Or
Rsync-partial-progress-rsh=ssh $user@$host:$remote_file $destination_file remote-> local
20. Analyze traffic through SSH W / WIRESHARK
Ssh root@server.com 'tshark-f "port! 22"-w -' | wireshark-k-I-
Use tshark to capture network traffic on remote hosts, send raw pcap data over a SSH connection, and show in wireshark that pressing Ctrl+C stops capture, but also closes the wireshark window. You can pass a "- c #" parameter to tshark to capture only the packet type specified by "#" or redirect data through named pipes instead of transmitting it directly to wireshark through SSH. I suggest you filter packets to save bandwidth. Tshark can use tcpdump instead of:
Ssh root@example.com tcpdump-w-'port! 22' | wireshark-k-I-
21. Keep the SSH session open permanently
Autossh-M50000-t server.example.com 'screen-raAd mysession'
After opening a SSH session, keep it permanently open, for laptop users, if you need to switch between Wi-Fi hotspots, you can ensure that the connection will not be lost after switching.
22. More stable, faster, stronger SSH client
Ssh-4-C-c blowfish-cbc
Force the use of IPv4, compress the data stream, and use Blowfish encryption.
23. Use cstream to control bandwidth
Tar-cj / backup | cstream-t 777k | ssh host 'tar-xj-C / backup'
Use bzip to compress the folder and transfer it to the remote host at 777k bit/s rate. Cstream has more features, please visit http://www.cons.org/cracauer/cstream.html#usage for more details, such as:
Echo w00t, iComm 733 + | cstream-b1-T2
24. Transfer the SSH public key to another machine step by step
Ssh-keygen; ssh-copy-id user@host; ssh user@host
This command combination allows you to log in without a password SSH. Note that if there is already a SSH key pair in the ~ / .ssh directory of the local machine, the new key generated by the ssh-keygen command may overwrite them. Ssh-copy-id copies the key to the remote host and appends it to the ~ / .ssh/authorized_keys file of the remote account. When using SSH connection, if you do not use the key password The remote shell is displayed shortly after calling ssh user@host.
25. Copy standard input (stdin) to your X11 buffer
Ssh user@host cat / path/to/some/file | xclip
Do you use scp to copy files to your work computer so that you can copy their contents to your email? Xclip can help you by copying standard input to the X11 buffer. All you need to do is click the middle mouse button to paste the contents of the buffer.
At this point, I believe you have a deeper understanding of "what are the commonly used and important SSH commands". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.