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/

例如scp /var/www/test.php [email protected]:/var/www/ 把本机/var/www/目录下的test.php文件上传到192.168.0.101这台服务器上的/var/www/目录中

 

2、从服务器上下载文件

下载文件我们经常使用wget,但是如果没有http服务,如何从服务器上下载文件呢?

scp username@servername:/path/filename /var/www/local_dir(本地目录)

例如scp [email protected]:/var/www/test.txt 把192.168.0.101上的/var/www/test.txt 的文件下载到/var/www/local_dir(本地目录)

 

3、从服务器下载整个目录

scp -r username@servername:/var/www/remote_dir/(远程目录) /var/www/local_dir(本地目录)

例如:scp -r [email protected]:/var/www/test /var/www/

 

4、上传目录到服务器

scp -r local_dir username@servername:remote_dir

例如:scp -r test [email protected]:/var/www/ 把当前目录下的test目录上传到服务器的/var/www/ 目录

Guess you like

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