ssh-keygen (press enter enter enter till you get the image)
user@ubuntu1:~$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa):
/home/user/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
5e:80:dd:36:0f:00:b6:58:bc:ae:a4:87:c8:bd:c1:f8 user@ubuntu1
The key's randomart image is:
+--[ RSA 2048]----+
| .+.. |
| +.+ o |
| . o.o = |
| . o + |
| . S . . |
| o . .. . |
|.o.* . . |
|..+.+ |
| E. |
+-----------------+
ssh-copy-id -i user@server.com.
Вы увидите следующее
(как только он попросит пароль)
user@ubuntu1:~$ ssh-copy-id -i root@ip
root@ip's password:
Теперь попробуйте войти в систему с помощью «ssh» root @ ip '"и зарегистрируйтесь:
~/.ssh/authorized_keys
, чтобы убедиться, что мы не добавили лишние ключи, которых вы не ожидали.
Теперь вы сможете выполнять ssh без запроса пароляС помощью awk вы можете просто сделать
awk '{split($3,a,":"); print > "test"a[1]+1".txt";}' test.txt
В чистом bash я не уверен, что лучший способ - хотя вы могли бы сделать что-то вроде
while read -r line; do
read -r a b c d <<< "$line"
printf -v outfile "test%d.txt" $(( ${c%%:*} + 1 ))
printf "%s\n" "$line" >> "$outfile"
done < test.txt
Попробуйте этот скрипт:
#!/bin/bash
while read line; do
HOUR=`echo $line | cut -d' ' -f3 | cut -d':' -f1`;
echo $line >> test-$HOUR.txt;
done < test.txt
Для каждой строки в файле команда cut сначала разделит строку на space, затем на :. Результат используется как суффикс для файла.
Выходные данные:
file-00.txt file-01.txt file-02.txt
, содержащие строку для часа 00, 01 и т. Д.