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.

asked Nov 19, 2017 by harryxiyou (5,830 points)

1 Answer

Best answer

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

> a@A:~> cat .ssh/ | 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 Nov 19, 2017 by harryxiyou (5,830 points)

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
commented Nov 19, 2017 by Eric Z Ma (44,280 points)

Sure, it works. Thank you for comments.

commented Nov 19, 2017 by harryxiyou (5,830 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost