ssh remote login + view system version + upload and download using scp command

Simple example of ssh remote login command
 
The ssh command is used to remotely log in to a Linux host.
 
Common format: ssh [-l login_name] [-p port] [user@]hostname
More details can be viewed with ssh -h.
 
Example
 
Without specifying a user:
 
ssh 192.168.0.11
 
Designated User:
 
ssh -l root 192.168.0.11
 
 
Check the system version:
cat /etc/redhat-release
 
If you have modified the ssh login port, you can:
 
ssh -p 12333 192.168.0.11
 
ssh -l root -p 12333 216.230.230.114
 
ssh -p 12333 [email protected]
 
In addition, modify the configuration file /etc/ssh/sshd_config, you can change the ssh login port and prohibit root login. Changing the port can prevent it from being port scanned.
 
Edit configuration file:
 
vim /etc/ssh/sshd_config
 
Find #Port 22, uncomment it, and modify it to a five-digit port:
 
Port 12333
 
Find #PermitRootLogin yes, remove the comment, and modify it to:
 
PermitRootLogin no
 
Restart the sshd service:
 
service sshd restart
 
 

After I log in with the terminal under mac, I feel worried when I want to upload a file. Is it possible to open an ftp?

I searched, and sure enough, there is a direct command line tool, the name is SCP

It is used as follows:

1. Upload the local file to the server

scp /path/filename username@servername:/path/

For example, scp /var/www/test.php [email protected]:/var/www/ upload the test.php file in the /var/www/ directory of the local machine to /var/www on the server 192.168.0.101 / directory

 

2. Download the file from the server

We often use wget to download files, but if there is no http service, how to download files from the server?

scp username@servername:/path/filename / var/www/local_dir (local directory)

For example, scp [email protected]:/var/www/test.txt downloads the file /var/www/test.txt on 192.168.0.101 to /var/www/local_dir (local directory)

 

3. Download the entire directory from the server

scp -r username@servername:/ var/www/remote_dir/ (remote directory) / var/www/local_dir (local directory)

For example: scp -r [email protected]:/var/www/test /var/www/

 

4. Upload the directory to the server

scp -r local_dir username@servername:remote_dir

For example: scp -r test [email protected]:/var/www/ Upload the test directory in the current directory to the /var/www/ directory of the server

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324951711&siteId=291194637