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 ...
随机推荐
- div下面多个a标签的点击事件,并且获取a的属性
$('.fensiselect').on('click','a',function(){ var id= $(this).attr('fanid'); alert(id) })
- linux下面设置密码失效参考
chage -E 2005-12-31 user1 设置用户口令的失效期限
- 第三篇:jmeter的作用域和执行顺序
1.元件的作用域: 8类可执行的元件,testplan和threadgroup不属于可执行的元件:这些元件中,取样器,是典型的不与其他元件发生交互作用的元件,逻辑控制器只对其子节点的取样器有效,而其他 ...
- 解题(MiGong--迷宫问题(深度搜索))
题目描述 定义一个二维数组N*M(其中2<=N<=10;2<=M<=10),如5 × 5数组下所示: int maze[5][5] = { 0, 1, 0, 0, 0, 0, ...
- STOP OUR NEGATIVE THOUGHTS
Do you ever feel like you're in over your head and at any moment you're going to burst? You're not a ...
- MySQL 按指定字段自定义列表排序
问题描述 大家都知道, mysql 中按某字段升序排列的 SQL 为 (以 id 为例, 下同): SELECT * FROM `MyTable` WHERE `id` IN (1, 7, 3, 5) ...
- 关于CDh5.13.1 HDFS启用HA(High Availability)注意事情--(JournalNode 只有一个编辑路径)
原因为:主机名不能为域名.更换成hadoop64 这种解决.
- [剑指Offer]24-反转链表
题目链接 https://www.nowcoder.com/practice/75e878df47f24fdc9dc3e400ec6058ca?tpId=13&tqId=11168&t ...
- swift - 16进制颜色扩展(1.支持# 2.支持不带# , 3支持带0X)
/** * 设置16进制颜色: * 可识别类型 * 1:有# * 2:没有# * 3:含有0X */ extension UIColor{ class func hexadecimalColor(he ...
- 浅谈前端三大框架Angular、react、vue
每个框架都不可避免会有自己的一些特点,从而会对使用者有一定的要求,这些要求就是主张,主张有强有弱,它的强势程度会影响在业务开发中的使用方式. 一.Angular,它两个版本都是强主张的,如果你用它,必 ...