How can I login without password and run command in server at a local machine remotely?

Login without PWD is fast and efficient. Running commands in server from local machine also have these benefits.

login without PWD: add PC A’s public key to PC B’s authorized keys.

> a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
> b@B's password:

Run command remotely

ssh root@MachineB "ls"

NOTE: running commands remotely is dangerous since there might be some ENVIRONMENT conflicts.


ssh-copy-id can replace the manual way of the adding the public key to a remote account’s authorized_keys:

$ ssh-copy-id b@B

Sure, it works. Thank you for comments.

Similar Posts

  • | |

    How to Statically Link OCaml Programs

    Static linking is preferred for some cases although it has its own various problems. Static building/linking is not always possible for some languages on some platform. For OCaml, the answer to this question is yes. In this post, we will introduce 2 methods to statically linking OCaml: static linking with runtime glibc required and static…

  • Question2answer: show excerpt in the RSS feed

    There is a “Include full text in feeds:” option in the “RSS feeds” configuration panel but no options/method to only show excerpt instead of the “full text” or nothing for RSS feeds. This need to hack the question2answer source code. Details are in the answer. The changes based on Question2asnwer 1.5.4: diff –git a/qa-include/qa-index.php b/qa-include/qa-index.php…

  • How to force a checkpointing of metadata in HDFS?

    HDFS SecondaraNameNode log shows 2017-08-06 10:54:14,488 ERROR org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode: Exception in doCheckpoint java.io.IOException: Inconsistent checkpoint fields. LV = -63 namespaceID = 1920275013 cTime = 0 ; clusterId = CID-f38880ba-3415-4277-8abf-b5c2848b7a63 ; blockpoolId = BP-578888813-10.6.1.2-1497278556180. Expecting respectively: -63; 263120692; 0; CID-d22222fd-e28a-4b2d-bd2a-f60e1f0ad1b1; BP-622207878-10.6.1.2-1497242227638. at org.apache.hadoop.hdfs.server.namenode.CheckpointSignature.validateStorageInfo(CheckpointSignature.java:134) at org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode.doCheckpoint(SecondaryNameNode.java:531) at org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode.doWork(SecondaryNameNode.java:395) at org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode$1.run(SecondaryNameNode.java:361) at org.apache.hadoop.security.SecurityUtil.doAsLoginUserOrFatal(SecurityUtil.java:415) at org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode.run(SecondaryNameNode.java:357) It seems the checkpoint…

  • Formatting code shortcuts in Eclipse

    Formatting code shortcuts in Eclipse. Shortcut: Ctrl + Shift + F No need to select the code. Read more: C++ cout formatting output Large-but-correctly-aligned-and-optimized code is faster than less-bytes-per-instruction/opcode-packed code How to get the assembly code for OCaml code generated by ocamlopt? Google Chrome keyboard and mouse shortcuts for Linux and Windows In Vim, are…

Leave a Reply

Your email address will not be published. Required fields are marked *