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 ...
随机推荐
- mongodb数据到MySQL数据库 的迁移步骤
废话少说,直接上干货. 1.mongoexport -d shengyang -c testData -f _id,x,name,name1,name2 --type=csv -o new.csv 用 ...
- Java中Properties集合总结
一:定义 表示一个持久的集,可以存在流中或者从流中加载.用来读取Java的配置文件,在Java中为.properties为后缀名的文本文件. 二:特点 是 Hashtable子类,map集合方法都可以 ...
- prompt
[prompt] prompt() 方法用于显示可提示用户进行输入的对话框. prompt(text,defaultText) 参数 描述 text 可选.要在对话框中显示的纯文本(而不是 HTML ...
- 为什么要用MarkDown?
[为什么要用MarkDown?] 大部分作家用 Word 或 Pages 写作,过去的文档也大都以 .doc, .docx 格式或是 Pages 格式储存.还有人为了保证文稿发给谁都能正常打开,会用 ...
- java中几个happens-before规则
1. 程序顺序规则:一个线程中的每个操作,happens-before 该线程中的任意后续操作. 2.监视器锁规则:对一个锁的解锁, happens-before 于随后对这个锁的加锁操作 3.vol ...
- c++中的类(class)-----笔记(类模板)
1,一个模板类至少具有一个类参数,类参数是个符号以表示将要被某个确定数据类型代替的类型. #include<iostream> #include<string> using n ...
- DC之setup-hold time详解
转自一下站点: http://www.blogbus.com/bb2hh-logs/20463915.html
- 【资料整理】c#基础
.net基础:.net与C# .net是一个平台 c#是一门语言 .net的用途a.桌面应用程序 b.网站应用程序 c.专业游戏开发(XBOX360) d.嵌入式设备软件开发 e.智能手机APP开发 ...
- Angular之特性模块 ( Feature Module )
项目结构 一 创建特性模块,及其包含的组件.服务. ng g module art ng g component art/music ng g component art/dance ng g ser ...
- Mac安装MySQL数据库
一 下载及安装社区版MySQL和MySQL Workbench. 二 如果MySQL Workbench无法登陆,则系统偏好设置-MySQL-Initialize Database,选择legacy开 ...