How to execute sudo command in remote host via SSH
Question:
I have an interactive shell script, that at one place needs to ssh to another machine (Ubuntu based) and execute something as root (the user should enter his password, but the remote command should run like noted in the script):
# ...
ssh remote-machine 'sudo ls'
# ...
However, I always get this error message back:
sudo: no tty present and no askpass program specified
OK, that's quite clear. But how can I circumvent this? Something like this should happen:
$ ssh remote-machine 'sudo ls /'
[sudo] password for user1:
/bin
/etc
/var
Answer:
The wondrous ssh has a cure for everything. The point is to add the -t flag to force ssh to allocate a pseudo-tty:
ssh -t remote-server 'sudo ls'
How to execute sudo command in remote host via SSH的更多相关文章
- -bash: sudo: command not found Error and Solution
文章转自: http://www.cyberciti.biz/faq/debian-ubuntu-rhel-centos-linux-bash-sudo-command-not-found/ 安装su ...
- Linux:SSH错误"WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! "
hadoop@master:~$ scp /home/hadoop/.ssh/authorized_keys node3:/home/hadoop/.ssh/ @@@@@@@@@@@@@@@@@@@@ ...
- Netbeans and Remote Host for C/C++ Developing
Netbeans and Remote Host for C/C++ Developing 很久以来,因为我不适应在 Linux 下使用 Vim, GCC, GDB 开发 C/C++ 程序,所以我一直 ...
- SSH登录警告(WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!)
在配置本机与docker容器实现ssh无密码访问时出现以下报错 # federico @ linux in ~ [18:35:52] C:127$ sudo ssh-copy-id -i .ssh/i ...
- Bind 远程连接DNS服务器时出现 rndc: connection to remote host closed
使用命令:rndc -s 192.168.1.2 status 连接远程的bind 搭建的DNS服务器时出现下面的错误: rndc: connection to remote host close ...
- what codes does sudo command do in Linux?
sometime, to make your change of configuration file be effective to web application, we have to rest ...
- telnet报“Unable to connect to remote host:Connection refused”错误
Linux下面telnet ip 端口号 报错误"Unable to connect to remote host:Connection refused"的时候,大部分是目标机的端 ...
- WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED
原文地址:http://linuxme.blog.51cto.com/1850814/375752 今天将阿里云服务器更换了一下系统盘,重启成功后,再次通过终端访问阿里云的公网IP报以下信息: @@@ ...
- WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED解决方法
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ WARNING: REMOTE HOST IDENTIFICATION ...
随机推荐
- Redis原子计数器incr
一.前言在一些对高并发请求有限制的系统或者功能里,比如说秒杀活动,或者一些网站返回的当前用户过多,请稍后尝试.这些都是通过对同一时刻请求数量进行了限制,一般用作对后台系统的保护,防止系统因为过大的流量 ...
- centos7防火墙以设置以及关闭selinux
一.CentOS 7.X 关闭SELinux 1.查看 getenforce permissive 或者 enforcing模式 2.临时设置 setenforce 1 成为permissive模式 ...
- oracle导入大sql文件
最近遇到一个需要导入大SQL文件的问题,最先直接用SQL developer 导入大SQL文件,结果报IO Exception,只好采用sqlplus 导入,操作过程如下: sqlplus 用户名/密 ...
- spring boot 中使用 Redis 与 Log
spring boot + mybatis + redis 配置 1.application.yml #配置访问的URLserver: servlet-path: /web port: spring: ...
- getRequestURI getRequestURL 区别
参考 https://blog.csdn.net/gavid0124/article/details/45390999/ request.getRequestURL() 返回全路径 request.g ...
- Jboss 数据源密码明文加密
转载:https://blog.csdn.net/iberr/article/details/40896479 备注:解密小程序没有测试,知识了解了加密解密过程.对自己的帮助是看懂了连接数据库的配置, ...
- 斐波那契数列(python)
题目描述 大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项(从0开始,第0项为0). n<=39 # -*- coding:utf-8 -*- class Solut ...
- Linux之须知
1.服务器有哪些硬件? 主板,cpu,显卡,内存,硬盘,声卡,网卡 2.内存,CPU,硬盘的作用? cpu是管理与运算.内存:cpu和磁盘之间的缓冲设备,服务器关闭后,数据从内存中释放掉. CPU,电 ...
- Linux初级入门(一)
Linux是一种开源电脑操作系统内核,它是一个用C语言写成,符合POSIX标准的类Unix操作系统.Linux最早是由芬兰黑客 Linus Torvalds为尝试在英特尔x86架构上提供自由免费的类U ...
- RxJS之组合操作符 ( Angular环境 )
一 merge操作符 把多个 Observables 的值混合到一个 Observable 中 import { Component, OnInit } from '@angular/core'; i ...