Ubuntu: ssh-keygen

来源:互联网 发布:mac艺术字体下载大全 编辑:程序博客网 时间:2024/06/01 17:34

Install openssh-client first

sudo apt-get install openssh-client

Suppose

Computer A(192.168.1.111), Computer B(192.168.1.123)


Login Computer A

ssh-keygen -t [rsa|dsa]

this will generate: id_rsa, id_rsa.pub or id_dsa, id_dsa.pub


Copy the generated .pub to .ssh directory in Computer B

cat id_dsa.pub >> ~/.ssh/authorized_keys

or

cat id_rsa.pub >> ~/.ssh/authorized_keys

We can connect to Computer B in Computer A without password

ssh 192.168.1.123

Examples of ssh commands

ssh remote@192.168.1.120ssh -i ~/.ssh/id_rsa david@abc.xyz.comssh -i ~/.ssh/id_dsa sam@50.17.138.101 -o ServerAliveInterval=60  (Solve Broken pipe problem:-o ServerAliveInterval=60)

Examples of scp commands

scp -r to-remote remote@192.168.1.120:~/to-remote    (copy directory)sudo scp -i ~/.ssh/id_rsa app.zip david@abc.xyz.com:~/app.zip    (copy .zip package)
0 0
原创粉丝点击