当前位置:网站首页>Introduction to SSH Remote execution command
Introduction to SSH Remote execution command
2022-07-03 18:36:00 【Brother Xing plays with the clouds】
Before , Seeing it mostly means modifying /etc/sudoers, then NOPASSWD: designated cmd, But it really doesn't work , Without remote virtual terminal, this method is floating cloud ,Ubuntu10.04 Server Personal test !!
ssh Perform remote operations
Command format
ssh -p $port [email protected]$p 'cmd'
$port : ssh Connection port number $user: ssh Connection user name $ip:ssh Connected ip Address cmd: long-range The server Actions to be performed
preparation
Based on public-private key authentication or user name password authentication, it can ensure login to the remote local2 The server ( It's not a problem for people with basic operation and maintenance knowledge to do this )
cmd If it's a script , Note the absolute path problem ( A relative path is a hole when executed remotely )
Insufficient
- This command can meet most of our needs , But it is usually necessary to deploy a lot of things root jurisdiction , But there are several limitations :
- remote server local2 prohibit root The user login
- In the remote server script, use expect need send password , It's not safe enough
Execute remote server needs sudo Script for permissions
ssh Of -t Parameters
-t Force pseudo-tty allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.
Chinese translation : Is a virtual server that can provide a remote server tty terminal , With this parameter, we can enter our own authorization raising password on the virtual terminal of the remote server , Very safe
Command format
ssh -t -p $port [email protected]$ip 'cmd'
Sample script
#!/bin/bash
# Variable definitions ip_array=("192.168.1.1" "192.168.1.2" "192.168.1.3") user="test1" remote_cmd="/home/test/1.sh"
# Through... Locally ssh Execute the script of the remote server for ip in ${ip_array[*]} do if [ $ip = "192.168.1.1" ]; then port="7777" else port="22" fi ssh -t -p $port [email protected]$ip "remote_cmd" done
This method is still very convenient ,-t Virtualize the terminal of a remote server , It really saves a lot of time when multiple servers are deployed at the same time !
边栏推荐
- Sepconv (separable revolution) code recurrence
- English语法_形容词/副词3级 - 倍数表达
- Summary and Reflection on the third week of winter vacation
- Administrative division code acquisition
- Sensor debugging process
- Boost.Asio Library
- [combinatorics] generating function (use generating function to solve the number of solutions of indefinite equation example 2 | extended to integer solution)
- A. Berland Poker & 1000 [simple mathematical thinking]
- 204. Count prime
- Typescript official website tutorial
猜你喜欢

What is SQL get connection

Transformer T5 model read slowly
![AcWing 271. Teacher Yang's photographic arrangement [multidimensional DP]](/img/3d/6d61fefc62063596221f98999a863b.png)
AcWing 271. Teacher Yang's photographic arrangement [multidimensional DP]

Okaleido, a multimedia NFT aggregation platform, is about to go online, and a new NFT era may come

How does GCN use large convolution instead of small convolution? (the explanation of the paper includes super detailed notes + Chinese English comparison + pictures)

How to analyze the rising and falling rules of London gold trend chart
![[combinatorics] dislocation problem (recursive formula | general term formula | derivation process)*](/img/e8/67961bf8a589869bde2a0aa3e09605.jpg)
[combinatorics] dislocation problem (recursive formula | general term formula | derivation process)*

The second largest gay dating website in the world was exposed, and the status of programmers in 2022

22.2.14 -- station B login with code -for circular list form - 'no attribute' - 'needs to be in path selenium screenshot deviation -crop clipping error -bytesio(), etc

Install apache+php+mysql+phpmyadmin xampp and its error resolution
随机推荐
Closure and closure function
Solve the problem of inaccurate network traffic monitored by ZABBIX with SNMP
After the festival, a large number of people change careers. Is it still time to be 30? Listen to the experience of the past people
JS_ Array_ sort
[combinatorics] generating function (use generating function to solve the number of solutions of indefinite equation example 2 | extended to integer solution)
Summary and Reflection on the third week of winter vacation
Torch learning notes (7) -- take lenet as an example for dataload operation (detailed explanation + reserve knowledge supplement)
A. Berland Poker & 1000 [simple mathematical thinking]
[combinatorics] generating function (generating function application scenario | using generating function to solve recursive equation)
Torch learning notes (2) -- 11 common operation modes of tensor
12、 Service management
Bidding procurement scheme management of Oracle project management system
Sensor debugging process
189. Rotation array
Caddy server agent
On Data Mining
Computer graduation design PHP makeup sales Beauty shopping mall
2022-2028 global scar care product industry research and trend analysis report
2022-2028 global solid phase extraction column industry research and trend analysis report
Zero length array