当前位置:网站首页>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 !
边栏推荐
- Computer graduation design PHP campus address book telephone number inquiry system
- webcodecs
- Three gradient descent methods and code implementation
- 网格图中递增路径的数目[dfs逆向路径+记忆dfs]
- How to quickly view the inheritance methods of existing models in torchvision?
- [combinatorics] dislocation problem (recursive formula | general term formula | derivation process)*
- SDNUOJ1015
- 论文阅读 GloDyNE Global Topology Preserving Dynamic Network Embedding
- NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
- Torch learning notes (6) -- logistic regression model (self training)
猜你喜欢
Administrative division code acquisition
Sensor 调试流程
How to draw non overlapping bubble chart in MATLAB
2022-2028 global plasmid DNA cdmo industry research and trend analysis report
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
2022-2028 global petroleum pipe joint industry research and trend analysis report
Should I be laid off at the age of 40? IBM is suspected of age discrimination, calling its old employees "dinosaurs" and planning to dismiss, but the employees can't refute it
2022-2028 global lithium battery copper foil industry research and trend analysis report
[untitled]
Implementation of cqrs architecture mode under Kratos microservice framework
随机推荐
The vscode code is automatically modified to a compliance code when it is formatted and saved
图像24位深度转8位深度
Win 11 major updates, new features love love.
企业级自定义表单引擎解决方案(十二)--表单规则引擎2
Kratos微服务框架下实现CQRS架构模式
[combinatorics] generating function (example of using generating function to solve the number of solutions of indefinite equation)
[Tongxin UOS] scanner device management driver installation
English grammar_ Adjective / adverb Level 3 - multiple expression
[combinatorics] generating function (use generating function to solve the number of solutions of indefinite equation)
编程中常见的 Foo 是什么意思?
Chisel tutorial - 06 Phased summary: implement an FIR filter (chisel implements 4-bit FIR filter and parameterized FIR filter)
Torch learning notes (5) -- autograd
12、 Service management
A. Odd Selection【BruteForce】
Computer graduation design PHP makeup sales Beauty shopping mall
[combinatorics] generating function (generating function application scenario | using generating function to solve recursive equation)
Nodejs (01) - introductory tutorial
2022-2028 global physiotherapy clinic industry research and trend analysis report
[combinatorics] generating function (positive integer splitting | basic model of positive integer splitting | disordered splitting with restrictions)
Torch learning notes (1) -- 19 common ways to create tensor