https://www.cnblogs.com/asyang1/p/9467646.html
SSH is the Secure Shell Acronym for establishing secure communication protocol in the application layer basis.
First, check the SSH service is started
Ubuntu is no default SSH service, so if you want to check SSH service is installed.
Open the terminal type the following commands:
1 $ ps -e | grep ssh
2
3 7529 ? 00:00:00 sshd 4 7852 pts/1 00:00:00 ssh
If the input instruction is similar to the display shown in the figure, then the service is started SSH
Which represents sshd ssh-server is started, ssh ssh-client representation has started
Second, install SSH Server
Installing SSH client and server:
1 $ sudo apt-get install openssh-client
2
3 $ sudo apt-get install openssh-server
Third, start the SSH service
After installation is initiated by commands:
1 $ sudo /etc/init.d/ssh start
After starting the SSH service using the following command to determine whether the correct start:
$ Ps -e | grep ssh
If the launch is successful, the result will be similar to the first step occurs in the terminal
Fourth, modify SSH port number
SSH default port number is 22, needs SSH port numbers are subject to change, and then run the following command to open the SSH configuration file:
1 $ sudo gedit /etc/ssh/sshd_config
It can be seen as shown below:
After modifying the port number (Port), restart the SSH service to take effect the following command:
1 $ sudo /etc/init.d/ssh restart
Five, SSH remote login
After the SSH service starts, it can remote login, login command format is: ssh account @IP address, for example:
1 $ ssh user@10.234.5.81
Which account refers to the U buntu login account
If you know the IP address can be viewed via the following command:
1 $ ifconfig -a
Found shown below at the inputs of the instruction:
Wherein inet is the local IP address
After logging command input When prompted, enter U buntu under the account password, that can remotely log
If you want to quit remote login, you can enter the following command:
1 $ exit
Sixth, data transmission
It can achieve after completing the SSH service configuration SSH-based data transmission, the most commonly used commands is easy scp, scp command following are commonly used:
$ Scp -r usr @ 43.224. 34.73: / home / lk / root // remote IP address 43.224.34.73 under usr user's path is / home / lk all the files are copied to the local / root folder $ scp usr @ . 43.224 34.73: /home/lk/test.jar / root // copy under usr user remote IP address 43.224.34.73 path is / home / lk of test.jar files to the local / root folder $ scp -r / root usr @ 43.224. 34.73: / home / lk // under all the files local / root are copied to the remote IP address of 43.224.34.73 usr user path is / home / lk folder $ scp / the root / usr test.jar @ 43.224. 34.73: / home / lk // the local file test.jar / root is copied to the remote user at the IP address 43.224.34.73 path for usr / home / lk folder
scp general instruction format is: scp [parameters] [original path] [target path]
-R parameter which means: recursively copy the entire directory
references:
1, Detailed installation and landed under Ubuntu ssh services (ssh remote login)
SSH is the Secure Shell Acronym for establishing secure communication protocol in the application layer basis.
First, check the SSH service is started
Ubuntu is no default SSH service, so if you want to check SSH service is installed.
Open the terminal type the following commands:
1 $ ps -e | grep ssh
2
3 7529 ? 00:00:00 sshd 4 7852 pts/1 00:00:00 ssh
If the input instruction is similar to the display shown in the figure, then the service is started SSH
Which represents sshd ssh-server is started, ssh ssh-client representation has started
Second, install SSH Server
Installing SSH client and server:
1 $ sudo apt-get install openssh-client
2
3 $ sudo apt-get install openssh-server
Third, start the SSH service
After installation is initiated by commands:
1 $ sudo /etc/init.d/ssh start
After starting the SSH service using the following command to determine whether the correct start:
$ Ps -e | grep ssh
If the launch is successful, the result will be similar to the first step occurs in the terminal
Fourth, modify SSH port number
SSH default port number is 22, needs SSH port numbers are subject to change, and then run the following command to open the SSH configuration file:
1 $ sudo gedit /etc/ssh/sshd_config
It can be seen as shown below:
After modifying the port number (Port), restart the SSH service to take effect the following command:
1 $ sudo /etc/init.d/ssh restart
Five, SSH remote login
After the SSH service starts, it can remote login, login command format is: ssh account @IP address, for example:
1 $ ssh user@10.234.5.81
Which account refers to the U buntu login account
If you know the IP address can be viewed via the following command:
1 $ ifconfig -a
Found shown below at the inputs of the instruction:
Wherein inet is the local IP address
After logging command input When prompted, enter U buntu under the account password, that can remotely log
If you want to quit remote login, you can enter the following command:
1 $ exit
Sixth, data transmission
It can achieve after completing the SSH service configuration SSH-based data transmission, the most commonly used commands is easy scp, scp command following are commonly used:
$ scp -r usr@43.224.34.73:/home/lk /root //将远程IP地址为43.224.34.73的usr用户下路径为 /home/lk 的所有文件拷贝到本地 /root 文件夹中
$ scp usr@43.224.34.73:/home/lk/test.jar /root //将远程IP地址为43.224.34.73的usr用户下路径为 /home/lk 的test.jar文件拷贝到本地 /root 文件夹中 $ scp -r /root usr@43.224.34.73:/home/lk //将本地 /root 中的所有文件拷贝到远程IP地址为43.224.34.73的usr用户下路径为 /home/lk 的文件夹中 $ scp /root/test.jar usr@43.224.34.73:/home/lk //将本地 /root 中的test.jar文件拷贝到远程IP地址为43.224.34.73的usr用户下路径为 /home/lk 的文件夹中
scp的通用指令格式为:scp [参数] [原路径] [目标路径]
其中-r参数意为:递归复制整个目录
参考文献:
1, Detailed installation and landed under Ubuntu ssh services (ssh remote login)