当前位置:网站首页>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 !
边栏推荐
- Getting started with JDBC
- Transformer T5 model read slowly
- NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
- Have you learned the correct expression posture of programmers on Valentine's day?
- On Data Mining
- Image 24 bit depth to 8 bit depth
- [combinatorics] exponential generating function (example of exponential generating function solving multiple set arrangement)
- Caddy server agent
- How to analyze the rising and falling rules of London gold trend chart
- Typescript official website tutorial
猜你喜欢

Getting started with JDBC

How does GCN use large convolution instead of small convolution? (the explanation of the paper includes super detailed notes + Chinese English comparison + pictures)
![Golang string (string) and byte array ([]byte) are converted to each other](/img/41/20f445ef9de4adf2a2aa97828cb67f.jpg)
Golang string (string) and byte array ([]byte) are converted to each other

Prototype inheritance..

NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
![Lesson 13 of the Blue Bridge Cup -- tree array and line segment tree [exercise]](/img/da/0a282b4773fe3909d1e5e9d19f8549.jpg)
Lesson 13 of the Blue Bridge Cup -- tree array and line segment tree [exercise]

How to analyze the rising and falling rules of London gold trend chart

Have you learned the correct expression posture of programmers on Valentine's day?

Redis cache avalanche, penetration, breakdown

2022-2028 global marking ink industry research and trend analysis report
随机推荐
Win 11 major updates, new features love love.
Unsafe类的使用
SDNUOJ1015
Analysis of the reasons why enterprises build their own software development teams to use software manpower outsourcing services at the same time
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
[Yu Yue education] theoretical mechanics reference materials of Shanghai Jiaotong University
Raft log replication
[combinatorics] generating function (example of using generating function to solve the number of solutions of indefinite equation)
Read the paper glodyne global topology preserving dynamic network embedding
[combinatorics] generating function (commutative property | derivative property | integral property)
企业级自定义表单引擎解决方案(十二)--表单规则引擎2
[combinatorics] generating function (use generating function to solve the number of solutions of indefinite equation example 2 | extended to integer solution)
2022-2028 global sepsis treatment drug industry research and trend analysis report
Getting started with JDBC
Transformer T5 model read slowly
Prototype inheritance..
Torch learning notes (4) -- torch's dynamic calculation diagram
Computer graduation project PHP library book borrowing management system
What London Silver Trading software supports multiple languages
Zero length array