# Scp @localhost

**URL:** <https://www.debian-fr.org/t/scp-localhost/75786>\
**Category:** Support Debian\
**Created:** [Janvier 30, 2018, 11:30 UTC](https://www.debian-fr.org/t/scp-localhost/75786 "2018-01-30T11:30:20Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![littlejohn75](https://www.debian-fr.org/user_avatar/www.debian-fr.org/littlejohn75/32/3840_2.png) [@littlejohn75](https://www.debian-fr.org/u/littlejohn75)\
**Post date:** [Janvier 31, 2018, 12:50 UTC](https://www.debian-fr.org/t/scp-localhost/75786/6 "2018-01-31T00:50:56Z")

</div>

> [@](#):
>
> serverRemote ~ \>
> 
> Et là je suis sur le server.

Je vous vais demandé de lancer

```auto
ssh -v root@unServeurRemote.com id

```

C’est-à-dire de lancer la commande `id` sur le serveur

> [@](#):
>
> debug1: Connecting to [unServeurRemote.com](http://unServeurRemote.com) [adr.ip.server.remote] port 22.

Pourquoi vous vous amusez à éditer les commandes et les sorties ?

> [@](#):
>
> Le remote server accepte l’authentification. C’est après que ça coince

D’accord, on pourrait supprimer l’option `-v`.  
Mais ce qui coince c’est votre compréhension du problème.

> [@](#):
>
> là SSH va chercher une clé sur /root alors que j’execute en tant que kmc

Sur la machine locale seulement, sur le serveur distant vous êtes `root`

> [@](#):
>
> debug1: Authenticating to [unServeurRemote.com:22](http://unServeurRemote.com:22) as ‘root’

Devoir s’authentifier comme root sur un système distant pour simplement lire un fichier /tmp/test ne me paraît pas très utile ou pertinent (pour une copie de /tmp/test )  
Par contre, des commandes comme

```auto
ssh root@distant ls -l .ssh
cd /tmp
scp root@distant:.ssh/id_rsa.pub .
ls -l id_*

```

vous permettront de comprendre que scp n’est pas une commande privilégiée et donc cela ne peut pas remplacer `chown`.

```auto
fp2@debpacha:/tmp$ l authorized_keys 
4 -rw-r--r-- 1 fp2 fp2 246 janv. 31 01:33 authorized_keys
fp2@debpacha:/tmp$ sudo pwd
/tmp
fp2@debpacha:/tmp$ sudo chown root:root authorized_keys 
fp2@debpacha:/tmp$ sudo SSH_AUTH_SOCK=$SSH_AUTH_SOCK cp -p authorized_keys /root/.ssh
fp2@debpacha:/tmp$ sudo SSH_AUTH_SOCK=$SSH_AUTH_SOCK ssh localhost id
The authenticity of host 'localhost (::1)' can't be established.
ECDSA key fingerprint is SHA256:UN6vSlmphWYOvtU3Gr+JDiPro6FNTofHzG4Z7dB45rM.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.
uid=0(root) gid=0(root) groupes=0(root)
fp2@debpacha:/tmp$ sudo SSH_AUTH_SOCK=$SSH_AUTH_SOCK ssh root@localhost ls -l .ssh
total 8
-rw-r--r-- 1 root root 246 janv. 31 01:33 authorized_keys
-rw-r--r-- 1 root root 664 janv. 31 01:36 known_hosts
fp2@debpacha:/tmp$ ssh root@localhost ls -l .sshtotal 8
-rw-r--r-- 1 root root 246 janv. 31 01:33 authorized_keys
-rw-r--r-- 1 root root 664 janv. 31 01:36 known_hosts
fp2@debpacha:/tmp$ 

```

```auto
fp2@debpacha:/tmp$ scp root@localhost:.ssh/authorized_keys id_rsa.pub
authorized_keys 100% 246 493.7KB/s 00:00    
fp2@debpacha:/tmp$ l id*
4 -rw-r--r-- 1 fp2 fp2 246 janv. 31 01:44 id_rsa.pub
fp2@debpacha:/tmp$ 

```

Voir aussi [ma réponse à Michel](https://www.debian-fr.org/t/exercice-ssh-et-sudo/71247)

## Cordialement, Regards, Mit freundlichen Grüßen, مع تحياتي الخالصة

F. Petitjean  
Ingénieur civil du Génie Maritime.

« On ne perd pas son temps en aiguisant ses outils. »  
Proverbe français

---

_[View the full topic](https://www.debian-fr.org/t/scp-localhost/75786)._
