On the server side
mkdir ~/.ssh
chmod 700 ~/.ssh
On the local side
ssh-keygen -t <rsa name rsa is OK>
[ENTER]
[Passphrase]
[Confirm passphrase]
chmod 600 ~/.ssh/<rsa name>.pub
Local side
scp ~/.ssh/<rsa name>.pub user@ip:~/.ssh/authorized_keys
Edit the / etc / ssh / sshd_config file
RSAAuthentication yes
PubkeyAuthentication yes
PasswordAuthentication no
PermitRootLogin no
PasswordAuthentication yes
You may enter prohibition of login as root, password authentication permission, etc.
DenyUsers ALL
AllowUsers <user>
You may not allow connections other than
/usr/sbin/sshd -t
systemctl restart sshd.service
You will be asked for a passphrase every time you connect, so set it
ssh-add <Private key path>
Then, the passphrase will be asked, so enter it.
easy_install fabric
(When I was able to use it before but it can no longer be used, I tried raising the version and it worked. It is good to be able to flexibly change the version with pyenv etc.)
from fabric.api import run
def getHostname():
run("hostname")
If you created a file with a name other than fabfile.py, enter `-f <fabfile>`
.
<method>
Is for the above filegethostname
Is specified.
fab -H <Server ADDRESS> -u <Server USER> -f <fabfile> <method>
Recommended Posts