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.

Answered by harryxiyou.

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.

Weiwei Jia

Weiwei Jia is a Ph.D. student in the Department of Computer Science at New Jersey Institute of Technology since 2016. His research interests are include storage systems, operating systems and computer systems.

Leave a Reply

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