使用用户名user1连接test.server1
ssh -l user1 test.server1 或者:ssh user1@test.server1
ssh -l user1 -p 22 test.server1 # -p: 指定端口,默认的是22
使用scp和远端机器互相拷贝文件
scp user1@test.server1:/etc/lilo.conf /etc # 从远端的test.server1拷贝文件/etc/lilo.conf到本地目录/etc/下
scp /etc/lilo.conf user1@test.server1:/home/user1 # 将本地文件/etc/lilo.conf拷贝到远端主机test.server1的/home/user1下
不用输入密码,直接SSH登录远端主机
STEP 1 - 生成公钥和私钥
ssh-keygen -t rsa
公钥:identity.pub 私钥:identity
STEP2 - 将公钥identity.pub拷贝到远端主机的$HOME/.ssh/authorized_keys (this is a file)
scp ./identity.pub user1@test.server1:.ssh/authorized_keys
禁止root用ssh登录
# vi /etc/ssh/sshd_config
PermitRootLogin no
废除密码登录,强迫使用RSA验证
# vi /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication no
# service sshd restart
# su - user1
$ mkdir ~/.ssh 2>/dev/null
$ chmod 700 ~/.ssh
$ touch ~/.ssh/authorized_keys
$ chmod 644 ~/.ssh/authorized_keys